Language syntax

Basic types

  • Integers:10, -42, +1337

  • Strings: "Hello, world!"

  • Booleans: true, false

Maths

Basic maths are supported so you can do arithmetic or boolean logic:

1 + 1
b * b - 4 * a * c
(1 + 2) * 3
true || false
true || false && myVar
x % 2 == 0

Conditional execution

if (x == y) {
    ...
}

if (x < y) {
    ...
} else {
    ...
}

Loops

for (i in 0..10) {
    ...
}

Iterates in a range from 0 to 10 (inclusive).

You can also iterate on decreasing values:

for (i in 10..0) {
    ...
}

Iterates in a range from 10 to 0 (inclusive).

You can use «complex» expressions for the range bounds:

for (i in start..(a + b)) {
    ...
}

Printing data

display "hello";
display (1 + 2) * 3;
display true || false && true;

Prints three lines:

hello
9
true

Actor behavior definition

An actor behavior definition follows this pattern:

<actor type> (<state var1>, <state varN>) [<message item1>, <message itemN>] = <statements>

A behavior is executed when a message matching a pattern is received by an actor.

Example:

MyActor () [item1] = display item1;

MyActor (State) [item1, item2] = {
    display item1;
    display item2;
};

Tagged messages

To enable calling the right behavior of an actor with multiple behaviors of the same arity, one can tag the messages with literal values in the patterns.

Example:

MyActor () ["display-one"] = display 1;
MyActor () ["display-two"] = display 2;

These behaviors will be executed on receiving a message containing either "display-one" or "display-two".

Changing behavior

An actor can change its type (and so its behavior) based on a received message:

Empty ()  ["set", x] = become Full (x);

Full (X) ["get", sender] = {
    send [X] to sender;
    become Empty ()
};

Sending messages

send [42] to anActor;

send ["hello", 1337] to anotherActor;

Actor self reference

In a behavior, the self variable is a reference to the actor executing the code.

Creating actors instances

Instantiating an actor from a given type with a given state (e.g. MyActor (42)) is done like so:

myInstantiatedActor = create MyActor (42);