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 revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:objects [2007/07/02 13:15] jorgeat:tutorial:objects [2007/07/02 13:32] jorge
Line 68: Line 68:
     def z := 0;     def z := 0;
     def sumofsquares() {     def sumofsquares() {
-      super.sumofsquares() + z*z+      super^sumofsquares() + z*z
     }     }
   }   }
Line 79: Line 79:
     def z := 0;     def z := 0;
     def sumofsquares() {     def sumofsquares() {
-      super.sumofsquares() + z*z+      super^sumofsquares() + z*z
     }     }
   }   }
Line 101: Line 101:
  
 ===== First-class delegation ===== ===== First-class delegation =====
-AmbientTalk provides an explicit delegation operator ''^'' shown in the code below.+AmbientTalk provides an explicit delegation operator ''^''. The code below illustrates the use of this operator in the implementation of the ''init'' method of the ''point3D'' object.
  
 <code> <code>
Line 109: Line 109:
       super^init(aX, aY);       super^init(aX, aY);
       z := aZ;       z := aZ;
-    }+    };
   }   }
 </code> </code>
 +
 +A message sent to an object using this symbol (e.g. to the parent object in the example above) will first look for the method that matches the selector indicated in the message in this object (and its parents) and then execute the method body in the lexical scope of the message sender.
  
 ===== Encapsulation ===== ===== Encapsulation =====
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem