User Tools

Site Tools


at:tutorial:objects

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:objects [2007/07/10 12:42] tvcutsemat:tutorial:objects [2007/07/10 12:46] – fixed tvcutsem
Line 141: Line 141:
  
 ===== First-class delegation ===== ===== First-class delegation =====
-AmbientTalk provides an explicit delegation operator ''^'' (the "caret" or "hat" symbol). The code below illustrates the use of the ''^'' operator in the implementation of the ''init'' method of the ''point3D'' object.+AmbientTalk provides a special message-sending operator ''^'' (the "caret" or "hat" symbol) to express the //explicit// delegation of a message to an object. The code below illustrates the use of the ''^'' operator in the implementation of the ''init'' method of the ''point3D'' object.
  
 <code> <code>
-def point3D := extend: point with: { +def point3D := extend: point with: { 
-    def z := 0; +  def z := 0; 
-    def init(aX, aY, aZ) { +  def init(aX, aY, aZ) { 
-      super^init(aX, aY); +    super^init(aX, aY); 
-      z := aZ; +    z := aZ; 
-    }; +  }; 
-  }+}
 </code> </code>
  
-A message sent to an object using the ''^'' symbol (e.g. to the parent object in the example above) will start the method lookup in this object (and its parents) and then execute the method body in the lexical scope of the message sender (''self'' is bound to the message sender).+A message sent to an object using the ''^'' symbol (e.g. to the parent object in the example above) will start the method lookup in this object (and its parents) and then execute the method body with the ''self'' pseudovariable bound to the message sender.
  
 <note warning> <note warning>
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem