Reflection in Direct Style
A reflective language enables us to access, inspect, and/or modify the
language semantics from within the same language framework.
Although the degree of semantics exposure differs from one language to
another, the most powerful approach, referred to as the behavioral
reflection, exposes the entire language semantics (or the language
interpreter) that defines behavior of user programs for user
In this paper, we deal with the behavioral reflection in the context
of a functional language Scheme.
In particular, we show how to construct a reflective interpreter where
user programs are interpreted by the tower of metacircular
interpreters and have the ability to change any parts of the
interpreters during execution.
Its distinctive feature compared to the previous work is that the
metalevel interpreters observed by users are written in direct style.
Based on the past attempt of the present author, the current work
solves the level-shifting anomaly by defunctionalizing and inspecting
the top of the continuation frames.
The resulting system enables us to freely go up and down the levels
and access/modify the direct-style metalevel interpreter.
This is in contrast to the previous system where metalevel interpreters
were written in continuation-passing style (CPS) and only CPS functions
could be exposed to users for modification.