next up previous contents
Next: Message Passing Up: Writing Concurrent Programs Previous: Actor State Modification


Actor Creation

The actor reference is a new primitive type in SALSA. There are three approaches to obtain an actor reference: either by actor creation statement, the getReferenceByName() function, or passed arguments from messages. This section concentrates on actor creation and reference passing.

Writing a constructor in SALSA programming is similar to object construction in Java programming. For instance, one can declare the HelloWorld actor as follows:
 
// An actor reference with type HelloWorld
HelloWorld myRef;
 
   
To create an actor instance and return a reference to myRef, one can write code as follows:
 
// Assume the constructor of HelloWorld is: 
//   public HelloWorld() {}
myRef = new HelloWorld();
 
   
In SALSA, actor references are passed by reference, while object variables by value. Objects are passed by value to prevent shared memory and preserve encapsulation.



Wei-Jen Wang
2007-11-28