Inspired by the su esses of program generation, partial evaluation, and runtime ode generation, multi-stage languages were developed as a uniform, high-level, and prin ipled view of staging. Our urrent goal is to demonstrate the utility of these languages in a pra ti al implementation. As a rst step this paper presents MetaOCaml, a type-safe, multi-stage language, built as an extension to OCaml's byteode ompiler. Future-stage omputations are represented as sour e programs. This makes it possible to ensure typesafety, produ e better dynami ally ompiled ode, and apply ru ial runtime sour e-to-sour e transformations su h as tag elimination. We have used MetaOCaml to measure performan e for a set of small staged programs. The gains are onsistent with those of partial evaluation and runtime ode generation, and support the laim that multi-stage languages are well-suited for building staged interpreters, even when the runtime ompilation times are taken into a ount.
[1]
Markus Mock,et al.
A retrospective on: "an evaluation of staged run-time optimizations in DyC"
,
2004,
SIGP.
[2]
Walid Taha,et al.
Closed Types as a Simple Approach to Safe Imperative Multi-stage Programming
,
2000,
ICALP.
[3]
Flemming Nielson,et al.
Program transformations in a denotational setting
,
1981,
ACM Trans. Program. Lang. Syst..
[4]
Walid Taha,et al.
An Idealized MetaML: Simpler, and More Expressive
,
1999,
ESOP.
[5]
Peter Lee,et al.
Lightweight Run-Time Code Generation
,
1994,
PEPM.
[6]
Eugenio Moggi,et al.
Functor Categories and Two-Level Languages
,
1998,
FoSSaCS.