Behaviors Next: ObjectsUp: Introduction Previous: Introduction


A behavior is a declaration which associates a name to a command (or command block). For example the following behavior associates the name B to the command that waits for E to print OK!:

      behavior B 
         await E;{System.out.println("OK!")} 

A new fresh copy of the behavior B is started every time a run B command is executed, and thus several runs of the same behavior can coexist without interference. The binding between a run B command and the behavior B is established dynamically, when the command run is executed. A behavior can be re-declared with the following rules:

New statements can be dynamically added to a behavior, to be executed in parallel with it. The syntax to add a statement i to a behavior b is ``add i to b''. Like for behavior redeclarations, the effect of adding a statement to a behavior is postponed to the next instant.

Finally, note that behaviors can have event parameters (see[1] for details).