LISP and Symbolic Computation, 9(2/3)203-241
Duplication and Partial Evaluation --For a Better Understanding of Reflective Languages--
Kenichi Asai, Department of Information Science, Faculty of Science, The University of Tokyo, 7-3-1 Hongo, Bunkyo-Ku, Tokyo, 113, Japan
Satoshi Matsuoka, Department of Mathematical Engineering, Faculty of Engineering, The University of Tokyo, 7-3-1 Hongo, Bunkyo-Ku, Tokyo, 113, Japan
Akinori Yonezawa, Department of Information Science, Faculty of Science, The University of Tokyo, 7-3-1 Hongo, Bunkyo-Ku, Tokyo, 113, Japan
Abstract: This paper presents a general implementation
framework for reflective languages. It allows us to systematically
build reflective languages which have the following favorable
properties: (1) user programs are allowed to access and change (parts
of) metalevel interpreters, (2) reflective facilities are available at
every level, (hence there exists conceptually an infinite tower of
interpreters), and (3) the interpreter runs as efficiently as the
conventional (directly implemented) metacircular interpreter when
reflection is not used. Our scheme is divided into three
stages. First, we define interpreters which give the operational
semantics of each level, and conceptually construct the infinite tower
of these interpreters. They are then duplicated to obtain directly
executed interpreters, while introducing double interpretation to
maintain redefinability of interpreters. Finally, partial evaluation
is employed to collapse the double interpretation into single
interpretation. We illustrate our scheme by implementing a particular
reflective language called Black in Scheme, but it is general enough
to be applied to other reflective languages. The paper gives the
complete Scheme implementation of Black and demonstrates some
examples. We also show how a system with the delta abstraction
introduced by Blond can be constructed in our framework.
Keywords: reflection, partial evaluation, metacircular
interpreter, direct execution, interpretation, infinite regression
|
[local copy]
|
|