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 [2008/11/03 10:08] – * tvcutsemat:tutorial:actors [2008/11/04 10:11] – added tvcutsem
Line 138: Line 138:
  
 <note warning> <note warning>
-A word of warning: isolates are objects that are (deep) copied freely between actors. As a result, they should be objects whose actual object identity is of little importance. Usually, the identity of by-copy objects is determined by the value of some of the object's fields. Therefore, it is good practice to override the ''=='' method on isolates to compare isolates based on their semantic identity, rather than on their object identity. For example, equality for complex numbers should be defined as:+Isolates are objects that are (deep) copied freely between actors. As a result, they should be objects whose actual object identity is of little importance. Usually, the identity of by-copy objects is determined by the value of some of the object's fields. Therefore, it is good practice to override the ''=='' method on isolates to compare isolates based on their semantic identity, rather than on their object identity. For example, equality for complex numbers should be defined as:
 <code> <code>
 def ==(other) { def ==(other) {
Line 144: Line 144:
 } }
 </code> </code>
 +
 +On a related note, it is good practice to consider isolates as //immutable// objects, since modifying an isolate will only modify its local copy.
 </note> </note>
  
Line 169: Line 171:
 >>4 >>4
 </code> </code>
 +
 +<note>
 +Since AmbientTalk 2.12 the interpreter is smart enough to figure out the lexically free variables of an isolate itself. If no variables are explicitly listed, the interpreter will try to figure out which lexically free variables it should implicitly copy. Unlike explicitly listed variables (like ''|x|'' in the above example), these implicitly copied free variables are private to the isolate (so they cannot be accessed from outside the isolate).
 +</note>
  
 ===== Futures ===== ===== Futures =====
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag