Wolfgang De Meuter
Last revision: August 7th, 1996

Reflection in Agora


Agora is a reflective language, which means that it is possible to alter the interpreter from within Agora. Remember that Agora's syntax is determined by reifier messages. For example, a conditional is written as

cond ifTrue:exp1 ifFalse:exp2

These reifier messages are actually sent during evaluation. This is important since if allows the possibility to write new reifier messages in Agora. In order to illustrate the idea, the following is a running example in Agora96:

self reifier:context is:
[ "self accessed!" printlOn:cout;
  self super return ]
This definition defines (i.e. overrides) ther reifier self. It writes a message on the screen and then returnes the value of the old self(i.e. the standard implementation of self). Notice that the context parameter is an object of the interpreter. It is the environment in which the reifier is to be interpreted. Hence, the programmer of the new reifier can access an object from the interpreter. The object is said to be reified in Agora (to reify = to become a thing, to materialise). The inverse process is called absorbtion. This allows us to call the interpreter with an object that was implemented in Agora. The interpreter will communicate with the object as if it was one of its own objects. We define a reflective language as a language that supports both reification and absorbtion.

Notice that in Agora, reflection is very safe. It is impossible to mess up objects by reflective programming. This is due to the very simple mop of Agora.