next up previous
Next: Problem 2: Handling introspection Up: Research directions Previous: Catalogue of emerging techniques

   
Problem 1: Compilation of reflective towers

In the general case, as we have said before, interpreters in reflective towers implement complex levels of meta-interpretation. Each of them is actually a complete specification of a programming language that is used to implement the program of the level below. To get rid of them, an obvious solution is to provide a compiler that implements the corresponding language.

If we enlarge the scope of this observation to the whole reflective tower, we get an interesting peephole effect. For each level n in the reflective tower, the corresponding interpreter is a processor for the language . Hence, each level n can equally be implemented as a compiler from the language to the language , itself implemented by the processor of level n+1. The whole tower can therefore be viewed as a multistage compiler from the language in which the user program is written in the machine language in which the ultimate processor or the basic apply method is written.

The peephole effect suggests looking at three levels at a time, as through a peephole, and observe a compiling relationship between the language in which the level n-1 is written, implemented by the level n interpreter itself written in . By moving the peephole up in the reflective tower, we can reveal a sequence of compilations transforming the program of level 0 into a program of level 1 and so on.

Hence, a reflective tower can be represented as a multistage compiler, which are more and more pervasive in high-level programming language implementations. The process is illustrated in Figure 5. In this example, a program P is run on a four-level tower. P is written in the language implemented by the level 1 processor. The level 1 processor is written in the language , etc. By a series of compilations, P is transformed into a program written in , the language of the ultimate processor, which is directly implemented in hardware.


  
Figure 5: Peephole effect.

This kind of architecture is more and more common. We often see compilers producing intermediate programs in C that are then compiled using a C compiler. Serrano and Weiss [SW94] have even implemented an efficient CAML compiler by compiling from CAML to Scheme, then from Scheme to C and finally from C to machine language. This is exactly what we would like to do with reflective towers, modulo introspection which makes the process more complex.


next up previous
Next: Problem 2: Handling introspection Up: Research directions Previous: Catalogue of emerging techniques
Matt Hurlbut
1998-07-02