expand and define-macro
Posted: Thu Dec 09, 2004 3:09 pm
Lutz,
It would be nice to have expand work on stuff like
instead of having to do string manipulation like below
What I would like is to create a macro definition that performs
by just typing
although I haven't quite figured out how to do the parameters yet.
Note this is almost static scoping for macros (the variables within the context remain after the macro call). If context variables where deleted on leaving the call we would have static scoping. I wonder if contexts could be used to form a contiunation? Is it possible to make define-macro statically scoped in newLISP?
Eddie
It would be nice to have expand work on stuff like
Code: Select all
(setq a 'r)
(expand (a:a b) 'a ) => (r:r b)
Code: Select all
(define-macro (def-mac _dm _body)
(let (_s (string _dm))
(eval-string
(format "(context '%s) (define-macro (%s:%s) %s) (context 'MAIN)"
_s
_s
_s
(string (eval _body)))))
Code: Select all
(context 'my-setq)
(define-macro (my-setq:my-setq x y) (set x (eval y)))
(context MAIN)
Code: Select all
(def-mac (my-setq x y) (set x (eval y)))
Note this is almost static scoping for macros (the variables within the context remain after the macro call). If context variables where deleted on leaving the call we would have static scoping. I wonder if contexts could be used to form a contiunation? Is it possible to make define-macro statically scoped in newLISP?
Eddie