Tue Sep 23 08:54:38 CEST 2008
Staapl (http://zwizwa.be/staapl) is a 2-stage dynamically typed
metaprogramming system for the PLT Scheme family of programming
languages. It consists of a concatenative transformer language Coma
that operates on a stack machine language.
It is based on two main observations.
* An imperative stack machine model (abstracting a processor as a
Forth machine) works particularly well for small embedded
* Staging and partial evaluation are simple to express for
functional concatenative programming languages due to absence of
problems related to identifier hygiene.
Staapl's Scheme bridge consists of the dynamically typed functional
concatenative Scat language, implemented as a hygienic Scheme
macro. In its basic form, Scat is Joy with extensional compositions:
code quotations are not lists, but abstract entities represented by
Scheme closures. Scat compositions support quasiquotation for
lexically scoped template programming from Scheme, and use a hygienic
hierarchical name management system based on PLT Scheme's declarative
Staapl's code transformers are written in a derivative of Scat called
Coma, a functional concatenative language operating on stacks of stack
machine code instructions. Staapl contains a pattern matching
mechanism for implementing Coma primitives in Scheme, which is used to
implement partial evaluation and writing architecture
backends. Currently there is an optimizing backend for Microchip
Staapl contains a simplified Forth frontend that hides most of the
metaprogramming system. This Forth dialect has the standard
Forth-style metaprogramming removed and replaced with a mechanism
based on partial evaluation and template macros. It is possible to use
the Forth language as a stand-alone programming system.