Thanks Carl and Sam,<br>
<br><div class="gmail_quote">[snip]<br><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">`defmacro' in PLT Scheme runs at expansion time, just like all other macros.<br>
</blockquote><br>
<div><br>my bad indeed. My test was badly designed.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> So what is the correct way to (generically) compress this code without<br>
> losing run-time, i.e. to have a syntactical transformation?<br>
> Is it possible to define an hygienic macro without loss of genericity?<br>
> Is there a hygienic macro programming style that I could automatically use?<br>
<br>
</div>How about:<br>
<br>
#lang scheme<br>
<br>
(define-syntax-rule (mymacro f x y . body)<br>
(define (f x)<br>
(let ([y (foo x)]) . body)))<br>
<br>
(mymacro f x y<br>
<div class="im"> (bar x y y)<br>
(plop y x y)<br>
(baz x y))<br>
<br>
</div>(mymacro f2 x y (baz x y))<br></blockquote><div><br>Thanks, that's it.<br></div></div>I wonder why I couldn't find it myself...<br>The programming style is then to turn "free" variables in unhygienic macros into identifiers that are bound to one given in the macro call.<br>
<br>Thanks also for your fast replies!<br>Laurent<br><br><br>