Compiling a Reflective Language using MetaOCaml

Compiling a Reflective Language using MetaOCaml
复制标题

使用 MetaOCaml 编译反射语言

DOI:
10.1145/2658761.2658775
复制
发表时间:
2014
期刊:
International Conference on Generative Programming: Concepts and Experiences
影响因子:
--
通讯作者:
K.
K.
中科院分区:
--
文献类型:
--
作者:
Asai;K.

文献摘要

相似文献

反射语言使语言语义对用户程序开放,并允许他们在同一语言框架内访问、扩展和修改它。由于其高度的灵活性和表现力,它可以成为编程语言研究和动态环境中实际应用的理想平台。然而,有效地实现反射语言是极其困难的。在语言语义可以改变的情况下,编译需要部分求值器。本文报告了使用MetaOCaml作为反射语言编译器的经验。通过分段注释,MetaOCaml实现了与使用部分求值器相同的效果。与标准的部分求值器不同,MetaOCaml的运行机制使我们能够在当前运行时环境中使用专门化(编译)的代码。另一方面,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 extremely difficult. 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 semantics.