The following piece of code is the SALSA version of HelloWorld program:
1. /* HelloWorld.salsa */ 2. module examples; 3. behavior HelloWorld { 4. void act( String[] arguments ) { 5. standardOutput<-print( "Hello" )@ 6. standardOutput<-print( "World!" ); 7. } 8. } |
The first line is a comment. SALSA syntax is very similar to Java and you will notice it uses the style of Java programming. The module keyword is similar to the package keyword in Java. A module is a collection of related actor behaviors. A module can group several actor interfaces and behaviors. Line 4 starts the definition of the act message handler. In fact, every SALSA application must contain the following signature if it does have an act message handler:
void act( String[] arguments ) |
In lines 5 and 6, two messages are sent to the standardOutput actor. The arrow (<-) indicates message sending to an actor (in this case, the standardOutput actor). To guarantee that the messages are received in the same order they were sent, the @ sign is used to enforce the second message to be sent only after the first message has been processed. This is referred to as a token-passing continuation (see Section 3.4.1).