Sun Apr 26 10:42:44 CEST 2009
The thing is: what if rpn-parse will _not_ translate identifiers if it
deems they are not transformer bindings?
The idea beeing that parsing words only serve to translate a flat file
into forth syntax, annotating each atom with a compiler semantics.
There is really no way around using some kind of cursor into the final
data structure = the scheme expression.
An empty dictionary is equivalent to:
(begin (lambda (p) p))
With the cursor made explicit:
(begin (lambda (p) (C p)))
(begin (lambda (p) (C (push 123 p))))
compiling a reference to a in ns (foo):
(begin (lambda (p) (C (apply foo/a (push 123 p)))))
compiling the name tag 'bar in namespace (foo):
(begin (lambda (p) (apply foo/a (push 123 p)))
(define foo/bar (lambda (p) (C p))))
now, compiling the locals '(a b)'
I find it so increadibly difficult to switch between nested lambda
representation and a CPS/monadic style representation.
But, in words, what does the locals transform do?
It transforms the current lambda expression:
- it replaces it with a new lambda expression that applies the
expression collected upto now to its input stack.
- pops values off the stack and binds them lexically to constant
- expands the rest of the code inside this new context.
(before ...) (local ...) (after ...)
(let ((p-in (apply (program: before ...) p)))
(let-values (((p-popped local ...) (pop-stack p-in)))
(apply (program: after ...) p-popped))))
How does this translate to a flat representation?
- grabbing the (before ...) list isn't that difficult: it's already
in the dictionary.
- closing it needs access to its closing procedure.