Cind programming language

Language definition Examples Download Contact

Sending messages to objects

Program control flow is mostly based on sending messages to objects and executing functions.

Sending messages

Statement of sending message has a typical receiver-dot-message-parameters syntax. For example:

host.println("Hello")

is a sending message println to the object host with a vector of parameters ("Hello").

It is also possible to send message by name, by giving the string of the message name in the brackets [ ... ]. For example:

host.["print"+"ln"]("Hello")

which is equivalent to above example.

Any sent message will returns a value in response or throws an exception, just like executed function.

Object with assigned message to send, may be treated together as a function, that is, as a value of fun type. For example:

fun f = host.println; f("Hello"); // sending message f("Second time Hello!"); // sending another message

For more about executing functions see Functions and Function execution.

Catching messages

Messages sent to the object are intercepted depending on the type of the object.

In case of objects of basic class or monitor class, appropriate class method is selected to be executed, and if there is none, then default message catcher will be executed (see Classes).

In case of object of selector class, sended message will be hold until some selector thread calls corresponding accept instruction (see Selector class).

In case of system object, a sent message (if it was not optimized by the compiler) will execute internal built-in function, and that mostly depends on the execution software version.

When class of the object has no appropriate method and default message catcher is not defined, then uncatched message will be passed down in inheritance chain, to be catched by the next object in chain (see Class inheritance). When inheritance chain has cycle, and none of its objects catches the message, then execution software will throw an exception.



Cind programming language 1.0.4