[REBOL] Macro - function problems
From: robbo1mark::aol::com at: 12-Mar-2002 12:57
Hi everybody,
Iam looking for help to write a
MACRO transformation function.
Iam looking for the guru's on this list
to help me with some lexical scoping
and "Hygienic" problems I've been
having with regards to my 'MACRO
function.
My MACRO function takes three arguments
which are these
'name [word!] args [block!] body [block!]
and should construct a transformer function
which allows named words to produce an
executable expression (ie a paren! or
alternatively a 'DOES function) which
can be bound to a word and properly
handles (lexically substitutes) the correct
arguments and which can also allow for nestable
macro expressions!
here are some simple examples of what I mean
>> MACRO nil ['word] [set word zero]
>> nil b
== (set 'b zero) ; or func [] [set 'b zero]
>> source b
b: (set 'b zero) ; or func [] [set 'b zero]
>> b
== 0
>> source b
b: 0
and another example
>> MACRO printer ['word 'value] [print value]
>> printer test "Hello"
== (print "Hello) ; or func [] [print "Hello"]
>> source test
test: (print "Hello") ; or func [] [print "Hello"]
>> test
Hello
>> test
Hello
Obviously you could imagine more advanced and / or
exotic examples.
I can produce these functions individually making
use of things like 'compose, 'to-paren and 'quote
which is defined thus,
quote: func ['val] [:val]
However the deeper / more general solution and lexical
intricacies escape me and thus I need your help.
Thanks in advance,
mark Dickson