Thu Jul 31 18:09:24 CEST 2008


This is a classical evaluation order manipulation. I know what I want
to do from a high level, but I somehow don't understand the
particularities of it. Quasiquotation is really confusing.. Factoring
it in simple steps might help..

meta-pattern (M0) is a macro that generates a macro M1
M1 expands to a number of applications of a template defined in M0

Let's try to construct a toy example first.

What I don't understand is nesting of syntax-case, and nesting of
quasisyntax and unsyntax.

The rule: an unsyntax corresponds to the toplevel quasisyntax, just
like quasiquote, and nesting of syntax-case just binds new variables,
but the toplevel ones are still visible. Nothing special..

   Basicly, syntax-case is a binding mechanism that allows you to
   avoid unsyntax. Nested quote/unquote is a mess, so solving this
   with merging of namespaces (variables and metavariables) is more

   For higher order macros it's best to stick with syntax-case and
   syntax, and leave nested ellipsis and quasisyntax/unsyntax alone.

Looks like it's working now. It's quite readable.

I've also added a macro 'patterns-class that combines 'meta-pattern
and its invocation. This gives a pretty compact representation:

 (op    pe/op  opcode  w/op   ~op)
 ((+    +      addwf   w/+    ~+)
  (-    -      subwf   w/-    ~-)
  (and  and    andwf   w/and  ~and)
  (or   or     iorwf   w/or   ~or)
  (xor  xor    xorwf   w/xor  ~xor))
 ((w/op)              ([opcode INDF 1]))
 (([qw a] [qw b] op)  ([qw (tscat: a b pe/op)]))
 (([qw a] op)         (macro: ',a movlw w/op))
 ((op)                (macro: ~op))
 ((~op)               (macro: w<-top drop w/op)))