The actor model is nicely described by Gul Agha on his technical report, “Actors: a model of concurrent computation in distributed systems”.
On page 49 he explains the “become” command:
become <expression>
After calling “become X”, an actor will forward all his messages to another actor’s mailbox (X).
I’m not sure, however, how this is implemented (it it’s implemented at all) in languages like Erlang and Scala. Is it somethign I have to code manually? What about efficiency? Agha shows an implementation of a stack using message-passing. Every time a pop or push is performed, one more forwarding link is added to some actor… After hundreds of thousands of operations, I’d expect such an implementation to spend too much time forwarding messages and not doing actual work, unless some nice optimizations were performed under the hood.
So my question is: how is forwarding (or “become”) implemented in typical actor languages like Erlang, Scala (and libraries for other languages)?
Look on page 12 (page 26 of the PDF copy I have) of Agha’s paper “Actors: A Model of Concurrent Computation in Distributed System.” “become” is his actor language is how you specify #2, the new behavior for the actor. Forwarding messages to another actor is just one of many possible new behaviors.
I think with Scala actors you’re in essentially the same boat as with Erlang if you want the forwarding behavior. Under the hood, Scala “react” and “reactWithin” work much like become, because the partial function defined by the react block is the new behavior of the actor, but I’m not sure that similarity is even intentional.
Most (all?) “actor” implementations deviate fairly substantially from Hewitt’s actor model and Agha’s actor language. IIRC the portion of the language from specifying actors’ behavior in Agha’s langauge isn’t even Turing complete. The language as a whole only becomes Turing complete when you consider a configuration of actors. I’d say the relationship between the actor model and current actor frameworks is kind of like the relationship of object-orientation in SmallTalk to object-orientation in C++. There’s some concept transfer and similar terms, but in the details they’re very, very different.