For the full documentation, of which this is a summary, see Small Language Booklet
This summary assumes that you are familar with C. For a full list of differences between C and Small, again, see the full documentation.
new keyword. E.g. new variable
static keyword. static keyword, but outside of any function. stock. public keyword. public testvar
new public testvar
define. const between the keyword and variable name of a variable declaration. For example, to declare the variable var1 constant, you typenew const var1 = 2
var1 cannot be changed.
new msg[] = "A message." new ints[] = {1, 3, 4} new ints2[20] = {1, 3} // All other elements 0. new ints3[10] = {1, ... } // All elements = 1 new ints4[10] = {10, 20, ... } // Elements = 10 -> 100. // The difference can be negative. new ints5[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
testfunc(param) {
// Do something ...
// over a couple of lines.
}
You can pass by reference. That is, the parameter you pass is changed outside of the function. For example:
testfunc(¶m) {
param = 10
// The passed variable will be set to 10 outside of the function.
}
To pass an array:
testfunc(param[]) {
// Do something to the array
}
if (expression) statement1 else statement2
switch (expression) { case 0: statement1 // Can only be one statement. Look Ma, no breaks! case 1..3: // For values between 1 and 3 inclusive. statement2 default: // Optional statement3 }
while(expression) statement
do statement while (expression)
for (init_expression; before_iter_test_expression; after_iter_expression) statement
#assert constant_expression
#define pattern replacement
#define pattern(%1,%2,...) replacement
#include filename
#if constant_expression // Various bits of code #else // Other bits of code #endif
#undef pattern