Traditionally, objects encapsulate data which are processed by their methods. In reactive scripts we put the focus on behavioral aspects, and the task of defining and using variables and data is transferred to Java.
An object combines a body statement which is automatically executed at each instant, with attached methods which must be explicitly called to be executed. It has the syntax:
object O body methods M1 ... Mn end
This statement defines an object O with attachedmethods M1 ... Mn, whose semantics is:
do body || control run M1 by O-M1 || ... || control run Mn by O-Mn until O-destroy
Event O-destroy is used to destroy the object; see below. Note that, as opposed to behavior declarations, objects are statements which are immediately run.
The syntax to call the method M of an object O is send M to O, and its semantics is simply generate O-M.
These semantics definitions have several consequences:
Objects are removed from the interpretor by destroying them, using the destroy command. The removal of an object does not prevent it to execute for the current reaction: the removal becomes effective only at the next reaction.
This presentation shows that objects and methods enter in a rather natural way into the broadcast event driven approach, although different in spirit from it as method calls are not broadcast but sent to precise targets. Reactive scripts give both ways of programming in an unified framework.
In this paper we describe the implementation of reactive scripts on top of Java, using SugarCubes defined in the companion paper:
Actually, we directly use SugarCubes for most part of the language. The main items to implements are behaviors, runs, and objects.