Cind programming language

Language definition Examples Download Contact

Indicator objects

Indicator objects are a special objects, which can be accessed by name during code execution.
These are: this, under, above, current, host, caller and pocket.

Pointers to the inheritance chain

This objects can be accessed inside code of the class,
and they points to the elements of inheritance chain of the current object (see Class inheritance):

  • this - current object,
  • under - next object in inheritance chain,
  • above - first object in inheritance chain.

Example:

class c { .fib(x) { if (x <= 2) { return 1; } else { return this.fib(x-1) + this.fib(x-2); } } }

Pointer to function

Object current points to the current function or executed method or accepted message.
Example:

fun(x) { if (x <= 2) { return 1; } else { return current(x-1) + current(x-2); } }

Host

Object host represents execution host, usually physical machine (runtime machine), where program is being executed. List of methods offered by host object depends on the execution software implementation.
For example:

host.println("Hello");

prints out a text line on the output stream in the console version of execution software (see Cind console application).

Several different host objects may appear during program execution.
Each object in the Cind program is assigned to the one fixed host. This assignment is made when the object is created. Every time, when object's code is being executed (e.g. by calling its method or operator), then host object will always be changed to the one, assigned during creation, unless it will be locally overwritten.

Indicator object host can be locally overwritten using do-with statement:

do { ... } with host = ... ;

For example:

do { x = new a.b(); } with host = myhost;

this creates object of class a.b which will be assigned to some other host.
Notice, that the above object will be still created on the same execution machine, but will only have assigned different indicator object host, which can be accessed during execution of the code of its class.

Caller

Object caller represents code execution caller (e.g. calling application), and - like host object - its behaviour mostly depends on the machine implementation. The most common use, is to retrieve information about the caller, for example, his IP number.

The caller object is not assigned to the objects, but to the execution thread, which are executed by the caller, and also can be locally overwritten by do-with statement.
Example:

var mycaller = new over caller { .getName() { return "My new name"; } }; do { some_service.call(); } with caller = mycaller;

Pocket

Object pocket is an additional storage place assigned to the execution thread during code execution.

The idea is, that you can hold in the pocket whatever you want, and use it later. It is useful in larger systems, where for example you have some tools and don't want to pass them to the parameters every time (perhaps hundred times), so you are putting them into the pocket, and pull them out only when need them.

Examples:

do { host.println(pocket); } with pocket = "Hello!" var f = fun() { host.println("x = "+(pocket:x); }; do { f(); } with pocket = new { x:2; y:4 };

Cind programming language 1.0.4