Oh, good point! Yes, that sounds like it should work well, sorry I didn&#39;t think of it.<div><br></div><div>Robby<br><br>On Wednesday, November 21, 2012, Tobias Hammer  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, 21 Nov 2012 15:33:06 +0100, Greg Hendershott &lt;<a>greghendershott@gmail.com</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The lexical context you&#39;re picking up to put on #&#39;args in the lam<br>
macro is the context that&#39;s sitting on the parentheses in the first<br>
argument to &#39;lam&#39; in the body of &#39;expand-to-lam&#39;. that context has no<br>
&quot;x&quot; bound.<br>
</blockquote>
<br>
OK, that explains why x is not bound. Thanks!<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is the trouble with these kinds of macros: you have to be careful<br>
to propagate the correct lexical information thru. In this case, you<br>
can either change expand-to-lam to carry its argument&#39;s lexical<br>
context onto that open paren there or you can change lam to use a<br>
different spot to get its lexical information (one that&#39;s already<br>
being carried thru, eg the context on the actual variables for<br>
example).<br>
</blockquote>
<br>
I want lam to be usable by other macros without the latter needing to<br>
cooperate explicitly; I want them to &quot;just work&quot;. So I prefer the<br>
second way.<br>
</blockquote>
<br>
As Robby explained you are using the context of the list of args for all arguments,<br>
which is in this case a wrong one. One context that should be valid in all cases<br>
in your example is the one of the arguments itself. If you unpack the<br>
arguments, do whatever you want to them and then reapply the context you stripped before,<br>
it should (as far as i understand) work:<br>
<br>
(define-syntax (lam stx)<br>
  (syntax-case stx ()<br>
    [(_ args body ...)<br>
     (with-syntax ([conv-args (for/list ([a (syntax-&gt;list #&#39;args)])<br>
                                (define a-datum (syntax-&gt;datum a))<br>
                                ;; do whatever you want with a-datum<br>
                                (datum-&gt;syntax a a-datum))])<br>
     #`(lambda conv-args<br>
         body ...))]))<br>
<br>
Other macros only have to cooperate in the &#39;normal&#39; way, i.e. they have to make sure<br>
that the arguments they pass in have the right context.<br>
<br>
Tobias<br>
</blockquote></div>