at:tutorial:actors
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:actors [2007/04/01 11:54] – finished tvcutsem | at:tutorial:actors [2007/04/01 12:21] – added tvcutsem | ||
---|---|---|---|
Line 35: | Line 35: | ||
=== Asynchronous Message Sending === | === Asynchronous Message Sending === | ||
+ | |||
+ | AmbientTalk, | ||
+ | |||
+ | Far references, like the reference stored in the variable '' | ||
+ | |||
+ | Hence, given the example above, the method '' | ||
+ | |||
+ | < | ||
+ | > | ||
+ | >>nil | ||
+ | </ | ||
+ | |||
+ | The above code is simple enough to understand: the '' | ||
+ | |||
+ | But what happens when the method to invoke asynchronously has parameters that need to be passed. How does parameter passing work in the context of inter-actor message sending? The rules are simple enough: | ||
+ | - Objects are always passed **by reference** | ||
+ | - Native data types like numbers, | ||
+ | |||
+ | When an object is passed by reference, we mean that the formal parameter of a method will be bound to a far reference to the original object. When it is passed by copy, the formal parameter will be bound to a local copy of the object. For example, consider the following '' | ||
+ | |||
+ | < | ||
+ | >>def calculator := actor: { | ||
+ | def add(x, | ||
+ | customer< | ||
+ | }; | ||
+ | }; | ||
+ | ><far ref to:< | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | < | ||
+ | >> | ||
+ | def result(sum) { | ||
+ | system.println(" | ||
+ | }; | ||
+ | }; | ||
+ | >nil | ||
+ | </ | ||
+ | |||
+ | Because of the parameter passing rules described above, the '' | ||
+ | |||
+ | < | ||
+ | sum = 3 | ||
+ | </ | ||
+ | |||
+ | futures | ||
=== Isolates === | === Isolates === | ||
+ | |||
+ | isolate stripe, by-copy, scoping rules, no external method defs | ||
=== Actor Mirrors === | === Actor Mirrors === | ||
+ | |||
+ | explain: mirror factory, message creation, message sending, install | ||
+ | |||
+ | === Nesting Actors === | ||
+ | |||
+ | lexical scoping rules for nested actors |
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag