<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 12, 2011, at 6:41 AM, Maurizio Giordano wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(32, 32, 32); "><div>Hi Matthias, hi schemers,</div>
<br><div class="gmail_quote"><div class="im" style="color: rgb(80, 0, 80); ">2011/7/11 Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank" style="color: rgb(103, 117, 58); ">matthias@ccs.neu.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<br>Now I don't understand at all why you want to use eval in the macro.<br>If the right-hand side just returned the lambda that you have there,<br>it would automatically capture the variables in the context of the<br>
gama rule.<br><br></blockquote><div> </div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
Have you tried just returning the lambda as is from the macro?<br><div><div></div><div><br></div></div></blockquote></div><div>I tried but it doesn't work! Here you find a sample of what you suggest:</div><div>---------------</div>
<div><div>(define-syntax mymacro</div><div> (syntax-rules (prova)</div><div> [(mymacro input ...)</div><div> (lambda (z) (list input ...) (+ z extern-var))]))</div><div><br></div><div>> (let* ((extern-var 2) (f (mymacro x y))) (f 1))</div>
<div>reference to undefined identifier: extern-var</div></div></div></span></div></blockquote><div><br></div><div>Here is what I meant: </div><div><br></div><div><div>#lang racket</div><div><br></div><div>(define-syntax-rule</div><div> (mm x)</div><div> (lambda (w) (displayln `(,x)) (+ w x)))</div><div><br></div><div>(define f </div><div> (let ([a 10])</div><div> (mm a)))</div><div><br></div><div>(f 42)</div><div> </div></div><div>More later -- Matthias</div><div><br></div></div></body></html>