Sat Apr 25 16:20:07 CEST 2009

macro continuations

Trying to avoid low-level macros, I do run into occasions where I need
to resort to CPS to be able to properly separate concerns (use macros
to "preprocess" other macro's input).

Usually this can be done by passing a macro continuation.  But what if
this continuation takes other arguments?  Maybe what is needed is a
"macro curry".

I've been playing with this when I tried writing the parser completely
in syntax-rules.  What I'm looking for here is a simple mechanism that
catches most of my specialization problems.

This is a bit more insidious than i thought.  My current approach
doesn't compose well... Let's just stick with simple one continuation
macros.... maybe local syntax would help?  Something to fake "lambda"
for macros?

The thing is: in CPS, primitives take an exptra continuation
argument.  However, to compose promitives requires the creation of new
continuations (in the form of closures).  This doesn't work for
macros, so the best way is to create local syntax.

It works with local syntax.  This is a bit tricky due to (... ...)
which i never got to intuitively understand very well (it seems upside

(define-syntax-rule (rpn-begin code ...)
        (syntax-rules (name)
          ((_ (()        ;; empty anonymous list
               ((name n) ;; entries need tagged name
                . tagged-code)
               (... ...)))
             (ns (rpn) (define n (rpn-lambda . tagged-code)))
             (... ...))))))
    (rpn-specialized-parse tx-mk code ...)))