Hi Romano,

Your solution is a close approxmiation of what Iam
looking for - which is basically a higher order 'MACRO
function which return a function bound to the 'name
argument which when evaluated binds a paren! or 'DOES
function to the first 'SPEC or 'ARGS argument and in
turn substitutes any / all remaining args in the 'SPEC
correctly in the resulting paren! or 'does function 'BODY .

As I said Iam sure it is possible to produce such a macro constructor function which 
even allows for "nested" macros within the 'args or 'body.

Will think more about your solution,

cheers & thanks,

Mark


In a message dated Tue, 12 Mar 2002  7:20:52 PM Eastern Standard Time, "Romano Paolo 
Tenca" <[EMAIL PROTECTED]> writes:

> Hi, Mark
> 
> > My MACRO function takes three arguments
> > which are these
> >
> > 'name [word!] args [block!] body [block!]
> >
> > 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"]
> 
> A solution (not a guru's one) could be:
> 
> macro: func ['w spec body][
>  set :w func spec compose/deep [set get (first spec) does compose/deep
> [(body)]]
> ]
> 
> which must be used with this syntax:
> 
> macro printer ['word 'value] [print (value)]
> 
> The substitution is made by compose, so the 'value must be between parens,
> this limits the use of parens in the body (but there is a workaround:
> (to-paren [])).
> Another more general solution could be a closure func.
> 
> In this example:
> 
> >> MACRO nil ['word] [set word zero]
> > b: (set 'b zero)   ; or func [] [set 'b zero]
> 
> the arg 'word is used twice:
> 
> 1) like the name of word to assign the macro
> 2) like a value in the macro body
> 
> The result is a macro which changes the word which points to itself. I think
> should be better to distingue the two.
> 
> BTW, with my solution, the nil should be:
> 
> macro nil ['word] [set (:word) zero]
> nil 'b
> source b
> b: func [][set 'b zero]
> 
> hope this helps
> 
> ---
> Ciao
> Romano
> 
> 
> 
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to