I suppose that would work. Sam suggested on #racket that I include the name of the argument in the macro definition:<div><br></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; font-size: 13px; background-color: rgb(255, 255, 255); ">(define-syntax-rule (foo bar form ...)<br>
</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; font-size: 13px; background-color: rgb(255, 255, 255); "> ((lambda (bar) form ...) "ARG"))<br></span></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">Then you could say:</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">(foo bar</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> ; Do stuff with bar here...</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> )</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><div class="gmail_quote">On Fri, Sep 16, 2011 at 1:12 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
Why not just store the arguments to lambda in some 'register' and ask for them?<br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br>
On Sep 16, 2011, at 4:09 PM, Daniel MacDougall wrote:<br>
<br>
> In this example it should return "ARG".<br>
><br>
> On Fri, Sep 16, 2011 at 1:08 PM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br>
><br>
><br>
> What should (foo bar) return?<br>
><br>
><br>
> On Sep 16, 2011, at 3:46 PM, Daniel MacDougall wrote:<br>
><br>
> > Is there any way to define a macro that expands out to a lambda, and then access the arguments passed to that lambda from outside the macro in the calling context?<br>
> > Here's an example of what I mean:<br>
> ><br>
> > #lang racket<br>
> ><br>
> > (define-syntax-rule (foo form ...)<br>
> > ((lambda (bar) form ...) "ARG"))<br>
> ><br>
> > (foo "Hello") ; => returns "Hello"<br>
> ><br>
> > (foo bar) ; => expand: unbound identifier in module in: bar<br>
> ><br>
> ><br>
> > I'd like access to the "bar" argument on the last line. Is this possible with Racket macros?<br>
> ><br>
> > Thanks,<br>
> > Daniel<br>
> > _________________________________________________<br>
> > For list-related administrative tasks:<br>
> > <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>