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/06/29 14:24] jorgeat:tutorial:objects [2007/06/29 14:31] jorge
Line 75: Line 75:
  
 ===== Delegation and dynamic inheritance ===== ===== Delegation and dynamic inheritance =====
-The parent of an object is bound to a field named ''super''. The delegation chain defined by an object and its parent (or chain of parents) determines the scope in which the message is looked up.+The parent of an object is bound to a field named ''super''. The delegation chain defined by an object and its parent (or chain of parents) determines the scope in which the message is looked up. As any field in AmbientTalk objects, the ''super'' field can be dynamically modified. 
 + 
 +<code> 
 +> def OpenConnection := object: {...}; 
 +    def ClosedConnection := object: {...}; 
 +    def Connection := object: { 
 +      def open() { 
 +        super := OpenConnection.new(); 
 +    }; 
 +    def close() { 
 +      super := ClosedConnection.new(); 
 +    }; 
 +  } 
 +</code>
  
 ===== First-class Delegation ===== ===== First-class Delegation =====
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem