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 revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:reflection [2007/07/13 09:37] jorgeat:tutorial:reflection [2007/07/13 10:24] jorge
Line 11: Line 11:
 def baseObject := object: { def baseObject := object: {
   def field := nil;   def field := nil;
-  def canonicalMethod() { nil } +  def canonicalMethod() { nil }; 
-  def keyworded: arg1 method: arg2 { nil }+  def keyworded: arg1 method: arg2 { nil };
 }; };
 def mirror := reflect: baseObject; def mirror := reflect: baseObject;
Line 34: Line 34:
  
 ===== Mirages ===== ===== Mirages =====
-Extending the AmbientTalk core language involves adding objects which have a different implementation for some of the default meta-operations. In this part of the tutorial we describe how a programmer could define objects which allow for the dynamic addition of unknown methods and fields. First of all, we need to create a mirror instance which we can use to create new objects from. This can be performed using the ''mirror:'' language construct as follows.+Extending the AmbientTalk core language involves adding objects which have a different implementation for some of the default meta-operations. In this part of the tutorialwe describe how a programmer could define objects which allow for the dynamic addition of unknown methods and fields. First of all, we need to create a mirror instance which we can use to create new objects from. This can be performed using the ''mirror:'' language construct as follows.
  
 <code> <code>
Line 47: Line 47:
     } else: {     } else: {
       super^doesNotUnderstand(selector);       super^doesNotUnderstand(selector);
-    } +    }; 
-  }+  };
 } }
 </code> </code>
  
-This mirror overrides the default implementation of the meta-operation ''doesNotUnderstand'' to report that a slot was selected which did not exist. The user is then provided with an opportunity to provide the missing definition or pass this opportunity in which case the default behaviour is executed (i.e. an error is being reported). The mirror defined above can subsequently used to create objects with an adapted meta-object protocol. Such objects are called **mirages** as they are not ordinary objects, but rather objects whose appearance and behaviour is defined by a custom mirror. Mirages are constructed using a variation on the ''object:'' constructor as is illustrated below.+This mirror overrides the default implementation of the meta-operation ''doesNotUnderstand'' to report that a slot was selected which did not exist. The user is then provided with an opportunity to provide the missing definition or pass this opportunity in which case the default behaviour is executed (i.e. an error is being reported). The mirror defined above can be used subsequently to create objects with an adapted meta-object protocol. Such objects are called **mirages** as they are not ordinary objects, but rather objects whose appearance and behaviour are defined by a custom mirror. Mirages are constructed using a variation on the ''object:'' constructor as is illustrated below.
  
 <code> <code>
at/tutorial/reflection.txt · Last modified: 2010/11/16 16:32 by tvcutsem