Very cool, thanks for the ideas.<div><br></div><div>Daniel<br><br><div class="gmail_quote">On Fri, Sep 16, 2011 at 1:20 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>
Yes, I was thinking of naming the register explicitly too.<br>
<div><div></div><div class="h5"><br>
On Sep 16, 2011, at 4:17 PM, Daniel MacDougall wrote:<br>
<br>
> I suppose that would work. Sam suggested on #racket that I include the name of the argument in the macro definition:<br>
><br>
> (define-syntax-rule (foo bar form ...)<br>
> ((lambda (bar) form ...) "ARG"))<br>
><br>
> Then you could say:<br>
><br>
> (foo bar<br>
> ; Do stuff with bar here...<br>
> )<br>
><br>
> On Fri, Sep 16, 2011 at 1:12 PM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br>
><br>
><br>
> Why not just store the arguments to lambda in some 'register' and ask for them?<br>
><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>
><br>
<br>
</div></div></blockquote></div><br></div>