Sat Apr 25 19:08:40 CEST 2009
Turning coma into a unit in terms of basic ops - or, maybe it's best
to dive into the parser first... Ok. let's try that then.
Let's do locals-tx.ss first.
One of the problems i saw coming was the use of semantics macros in
the parsing words... Simply, there is no way to do this without
passing some parameters into the transformer..
Let's see.. Instead of doing this in macro code, try it in plain rpn
The syntax is:
(| a b | b a)
The difficulty here is in finding the end of the code. Once this is
done it's quite straightforward.
(define-syntax-rule (rpn/locals: (a b) prog ...)
(let ((a (lambda (x) (immediate (p-car p) x)))
(b (lambda (x) (immediate (p-cadr p) x)))
(p+ (p-caddr p)))
(function (rpn: prog ...) p+))))
The convoluted nature of the old implementation seems to be mostly
about not being able to terminate the code properly. As an
s-expression, it's really trival.
So.. What about solving this in the postprocessor? Can't do that
since some identifiers might be interpreted as compile-time actions..
So probably the current way it works is already wrong: compile-time
bindings won't get shadowed! There's only one way: the body needs to
be expanded inside a context that has expanded the surrounding let
I'm going to change the local syntax stuff to explicitly named
transformers to make the expansions a bit less verbose.
This is the locals transformer:
(define-syntax (rpn-parse-locals stx)
(syntax-case stx ()
(param ...) code ...)
(let ((plist (syntax->list #'(param ...))))
(let-values (((p+ param ...) (pop-values p #,(length plist))))
(let #,(for/list ((p (syntax->list #'(param ...))))
#`(#,p (program: ',#,p)))
(function (program: code ...) p+)))))))))