Cind programming language

Language definition Examples Download Contact

Spaces

Spaces allows to organize code classes in sets.

Space is a set that is indentified by name, which includes some classes. Spaces are organized in tree, and can be accessed by extended name, that consists of names of all parent spaces, separated by dots.
For example, an instruction:

space flora.meadow.flower;

is a declaration of a space named flora.meadow.flower, and each class defined below that space declaration will belong to that space.

Each class can belong to the one space, or not belong to any. Accessing class that belongs to some space, require use of an extended name, which, just like name of the space, should be prefixed by the extended name of the space.
For example:

space flora.meadow.flower; // space declaration class leaf { // class ... }

and now, this class may be accessed by an extended name (even from the other spaces):

var x = new flora.meadow.flower.leaf();


An Extended name of a class can be also used as a type of a class (see Classes).

Push and pop spaces

There are special instruction to save currently selected space and restore it later, during code reading by the compiler. These are: push space and pop space.

Example of usage:

space a; // space "a" is selected class x { ... } .... context push space; // space "a" is remebered by compiler on some internal stack .... space b; // space "b" is selected class y { ... } .... context pop space; // space "a" is selected again, because it was restored claaa z { ... } ...

Above code declares 3 classes: a.x , b.y and a.z .



Cind programming language 1.0.4