This is an advanced topic. In order to understand it, please read about the Operational model first.
N-ary operators activation
A SubScript application is a constantly changing call graph that represents the current state of a script. Nodes are operators and operands. The application run is a constant change of the graph. SubScript virtual machine manages these changes by passing messages to individual nodes telling them what to do.
The procedure of N-ary operators activation is decided by the Continuation
message that they receive. This message decides, for instance, whether we should activate the next operand or whether we should terminate this N-ary operator with success. Usually, if the operator was not terminated, the Continuation
message schedules another Continuation
message to the very same operator in order for it to decide what to do next. Also, the Continuation
message is sent to the operator when some other messages are handled. Such messages as, for example, AAHappened
(it is sent when some of the children code-containing nodes executes its code).
So, roughly, the process of N-ary operators activation looks like a chain of Continuation
messages that they receive. In most cases, either exactly one operand of this operator is activated or this operator terminates as a result of Continuation
message handling.
Simple break
operand
The break
operand permanently stops the activation of an N-ary operator. This means, that the next Continuation
message received by it will terminate it. For instance:
script live = println("Hello") break println("World")
will output just “Hello”.
Optional break .
operand
The .
is an optional break operand. This means, that the next Continuation
message will not activate any other operand. However, it will not terminate the operator, and the second Continuation
message received will act normally.
Let’s have a look at the following script:
script live = println("Hello World") && ...
Note, that the ...
is a loop operand here, NOT a three separate optional break .
operands. If we run it, we’ll see no output. This is because the &&
operator activates all its operands prior to their execution. However, the ...
operand turns the &&
operator into an infinite loop with an infinite number of operands to activate. So they will never have a chance to be executed.
Now look at this script:
script live = println("Hello World") && . && ...
If you run it, you’ll see the infinite amount of “Hello World” output. Here, the .
optional break will break the activation of the &&
operator. The activation will resume only after the second Continuation
message, which is received after the println("Hello World")
executes.
Optional break loop ..
operand
The pattern of . && ...
is common and useful, so it got abstracted into a separate operand, ..
, in SubScript. The ..
operand will turn its N-ary operator in a loop and will optionally break its activation (just like .
does).
For example, the script discussed above can be written in the following way:
script live = println("Hello World") && ..