Compiling a Reflective Language using MetaOCaml
A reflective language makes the language semantics open to user
programs and allows them to access, extend, and modify it from within
the same language framework.
Because of its high flexibility and expressiveness,
it can be an ideal platform for programming language
research as well as practical applications in dynamic environments.
However, efficient implementation of a reflective language is
Under the circumstance where the language semantics can change, a
partial evaluator is required for compilation.
This paper reports on the experience of using MetaOCaml as a compiler
for a reflective language.
With staging annotations, MetaOCaml achieves the same effect as using
a partial evaluator.
Unlike the standard partial evaluator,
the run mechanism of MetaOCaml enables us to use
the specialized (compiled) code in the current runtime environment.
On the other hand, the lack of a binding-time analysis in MetaOCaml
prohibits us from compiling a user program under modified compiled