User Tools

Site Tools


at:tutorial:actors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
at:tutorial:actors [2007/04/01 11:46] – added tvcutsemat:tutorial:actors [2007/04/01 11:54] – finished tvcutsem
Line 22: Line 22:
  
 <code> <code>
-def a := actor: {+>def a := actor: {
   def sayHello() {   def sayHello() {
     system.println("Hello World")     system.println("Hello World")
   };   };
 }; };
 +>><far ref to:<object:1555668>>
 </code> </code>
 +
 +As you can see, actors are created similar to objects. The ''actor:'' method, defined in the global lexical scope, takes a closure as its sole argument and uses that closure to initialize the behaviour of the new actor. The creator of the actor immediately receives a so-called //far reference// to this behaviour object, and from that moment on the creating actor and the created actor run in parallel, each capable of processing incoming messages autonomously.
 +
 +So what exactly is a far reference to an object? The terminology stems from the E language: it is an object reference that refers to an object hosted by another actor. The main difference between regular object references and far references is that regular references allow direct, synchronous access to an object, while far references disallow such access. This is enforced by the kind of messages that these references can carry, as will be explained below.
  
 === Asynchronous Message Sending === === Asynchronous Message Sending ===
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag