# Metaprogramming and Concatenative Rewriting

## Tom Schouten — 2008-09-09 13:11:32

    Hello folks,

    I'm trying to write a paper about the core idea of Staapl from the

    perspective of concatenative code rewriting, and how a particular

    _implementation_ of this gives a convenient applicative -> concatenative

    metaprogramming framework.

    These two blog posts try to explain the mechanism:

    http://zwizwa.be/ramblings/staapl-blog/20080806-212034

    http://zwizwa.be/ramblings/staapl-blog/20080625-162839

    As side information a post that deals with the 'impedance match'

    between Scheme and the concatenative macro language, based on

    pattern matching and quasiquotation:

    http://zwizwa.be/ramblings/staapl-blog/20080526-203330

    I'm wondering mostly if this makes sense..  While using the abstractions

    in real life works beautifully, I have great trouble trying to explain

    in a few words why this all works so well.

    Basicly, it's the interplay of:

      * pattern matching for destruction/construction of stack machine code

      * using this for eager partial evaluation (implementing rewrite rules)

      * macro hygiene and lexical closures

    Any comment welcome.

    (Best one gets a free PIC kit ;)

    Cheers,

    Tom