User Tools

Site Tools


at:tutorial:reflection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
at:tutorial:reflection [2008/09/15 18:00]
tvcutsem
at:tutorial:reflection [2008/11/06 15:36]
elisag
Line 28: Line 28:
 </code> </code>
  
-The code excerpt presented above uses the mirror to //introspect// on an object and uses the ''listSlots'' meta-method. The result is a table of the slots (fields and methods) provided by this object. Notice that fields are represented as a combination of an accessor and a mutator method, conforming to the Uniform Access Principle as discussed in [[:at:tutorial:objects#uniform_access|chapter 5]]. Also note that the object has a field called ''super'', although this field was not explicitly defined. In AmbientTalk, ''super'' is defined implicitly for every object.+The code excerpt presented above uses the mirror to //introspect// on an object and uses the ''listSlots'' meta-method. The result is a table of the slots (fields and methods) provided by this object. Notice that fields are represented as a combination of an accessor and a mutator method, conforming to the Uniform Access Principle as discussed in [[:at:tutorial:objects#uniform_access|chapter 5]]. Also note that the object has a field called ''super'', although this field was not explicitly defined. In AmbientTalk, ''super'' is defined implicitly for every object. The picture below gives an overview of the different objects involved in the actor. 
 + 
 +{{:at:tutorial:meta-1.jpg|:at:tutorial:meta-1.jpg}}
  
 The code excerpt below shows how one can add and remove slots to and from an object, and how one can explicitly access values and invoke methods upon an object, reflectively: The code excerpt below shows how one can add and remove slots to and from an object, and how one can explicitly access values and invoke methods upon an object, reflectively:
Line 119: Line 121:
 </code> </code>
  
-In the code above, the closure passed to ''mirroredBy:'' is a //mirror construction closure//. This closure is applied to a new, empty mirage object and it is expected that it returns a new mirror that reflects upon this mirage. When the mirror is constructed, the object initialization closure is executed.+In the code above, the closure passed to ''mirroredBy:'' is a //mirror construction closure//. This closure is applied to a new, empty mirage object and it is expected that it returns a new mirror that reflects upon this mirage. When the mirror is constructed, the object initialization closure is executed. The picture below gives an overview of the different objects involved in the actor. 
 + 
 +{{:at:tutorial:meta-2.jpg|:at:tutorial:meta-2.jpg}} 
  
 When invoking the method ''m'' on the mirage, ''invoke'' will be invoked on the tracing mirror, causing the following behaviour: When invoking the method ''m'' on the mirage, ''invoke'' will be invoked on the tracing mirror, causing the following behaviour:
at/tutorial/reflection.txt · Last modified: 2010/11/16 16:32 by tvcutsem