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 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 (<-) indicated 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 world message to be sent only after the hello message has been processed. This is referred to as token-passing continuation.