[plt-scheme] Unhygienic macro not needed?

From: Laurent (laurent.orseau at gmail.com)
Date: Fri Nov 20 10:10:29 EST 2009

Thanks Carl and Sam,


`defmacro' in PLT Scheme runs at expansion time, just like all other macros.

my bad indeed. My test was badly designed.

> > So what is the correct way to (generically) compress this code without
> > losing run-time, i.e. to have a syntactical transformation?
> > Is it possible to define an hygienic macro without loss of genericity?
> > Is there a hygienic macro programming style  that I could automatically
> use?
> How about:
> #lang scheme
> (define-syntax-rule (mymacro f x y . body)
>  (define (f x)
>     (let ([y (foo x)]) . body)))
> (mymacro f x y
>     (bar x y y)
>    (plop y x y)
>    (baz x y))
> (mymacro f2 x y (baz x y))

Thanks, that's it.
I wonder why I couldn't find it myself...
The programming style is then to turn "free" variables in unhygienic macros
into identifiers that are bound to one given in the macro call.

Thanks also for your fast replies!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091120/236a873b/attachment.html>

Posted on the users mailing list.