Thu Aug 7 08:24:37 BST 2008

Staapl in a nutshell

Staapl aims to work out the claim that Forth is a decent machine
language on which to build DSLs using macros in Scheme style.

  * [UNROLLED REFLECTION] It places the the basic compositional forms
    of Forth (procedures, macros, parsing words) in a non-reflective
    declarative hierarchical language tower framework.  The main
    advantage is that it gives an declarative a-cyclic ``unrolled''
    layered language structure that is easier for metaprogramming.

  * [FUNCTIONAL PROGRAMMING] Staapl models Forth macros as a pure
    functional stack language, operating on a stack of (virtual)
    machine code instructions.  To this end it provides a pattern
    matching language for writing primitive code transformers in terms
    of instruction templates.

  * [PARTIAL EVALUATION] It uses the purely functional subset of Forth
    (words that operate on the top of the stack only) as a guide to
    derive a set of pattern matching rules that implement partial
    evaluation for this subset.  This is done by eagerly moving
    computations to compile time.

  * [PARAMETERIZED CODE GENERATION] The partial evaluation mechanism
    is generalized to use Scheme's data types, including its number
    system, to facilitate the construction of arbitrary code generator

  * [SCHEME] To avoid any aribitrarily introduced abstraction walls,
    all these mechanisms are available in and built on top of PLT
    Scheme modules.  This allows the construction of s-expression
    based DSLs by expanding code down to a concatenative machine

  * [INTERACTION] On top of the declarative structure, a toplevel
    interaction environment is provided that allows interactive code
    compilation and execution.  Care is taken to make this convenient,
    i.e. to provide simulation for common language constructs if they
    are not instantiated.

  * [CULTURE] Giving up Forth's traditional imperative self-reflective
    property and absence of intermediate representation dispenses with
    some minimalist elegance.  Staapl is very different in ``culture''
    from traditional Forth.