Download

Support

Brief Introduction to Small

This section describes the basics of Small, as compiled and interpreted with Embryo.

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.

Variables

Types

There is only one type, known as the "cell", which can hold an integer.

Scope

The scope and usage of a variable depends on its declaration.

Remember that the keywords above are to be used on their own. That is, for example:
 public testvar 
not:
 new public testvar 

Constants

You can declare constants in two ways:

Arrays

To declare an array, append square brackets to the end of the variable name. The following examples show how to declare arrays. Note the use of the ellipsis operator, which bases the array based on the last two declared values:

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}}

Note:
Array initialisers need to be constant.

Function Calls

A typical function declaration is as follows:

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(&param) {
  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
}

Note:
Arrays are passed by reference.

Control Structures.

Small has the following control structures, which similar to their C counterparts:

Preprocessor

The following preprocessor directives are available:

Copyright © Enlightenment.org

Embryo Documentation