I'm not sure where I picked it up, but I remembered the arguments being
called &form and &env, and googling for "clojure &form &env" led me to:
http://groups.google.com/group/clojure/browse_thread/thread/d710c290b67951a3/b827d46389110f26?lnk=gst&q=clojure+macro+%26env#b827d46389110f26
:

"&form contains the form how the *macro* was called. *&env* contains local

bindings in the *macro* environment. (At least this is what my little

test shows...) These magic parameters are given to all parameters, but

usually hidden. It's probably safe to ignore them if you don't know
what they really do."

-- 
Eivind Magnus Hvidevold
Cell: +47 926 78 423



On Sat, Oct 2, 2010 at 8:41 AM, Stefan Rohlfing
<stefan.rohlf...@gmail.com>wrote:

> @Jürgen and Chris
>
> Thank you very much for helping me enlarge my understanding of macros!
>
> I realize that learning the subtleties of a macro implementation is
> not easy but well worth the effort.
>
> It is also quite interesting that a macro as it seems takes two
> implicit extra arguments. I am curious what these arguments might be
> and hope someone can tell us.
>
> Stefan
>
> > Actually, it's not. That's becuase the compiler inserts a couple of
> > extra implicit arguments to all calls to macros. So in fact, my-infix,
> > at runtime, expects 3 arguments. Check this out:
> >
> > user=> (defmacro foo [x] x)
> > #'user/foo
> > user=> (foo 23)
> > 23
> > user=> (def foo2 (var-get #'foo))
> > #'user/foo2
> > user=> (foo2 23)
> > java.lang.IllegalArgumentException: Wrong number of args (1) passed
> > to: user$foo (NO_SOURCE_FILE:0)
> > user=> (foo2 23 34 45)
> > 45
> >
> > I hope that makes it clearer. I certainly feel like I understand
> > macros a little better after figuring this out.
> >
> > As for what exactly the two implicit args to macros are - I don't
> > know. Someone else will have to explain that.
> >
> > - Chris
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to