> If so, it's only the subforms not in operator position that get
> macroexpanded first. Otherwise
>
> user=> (defmacro qqq [] 'if)
> #'user/qqq
> user=> ((qqq) (even? 42) "boo!")
> #<CompilerException java.lang.Exception: Unable to resolve symbol: if
> in this context (NO_SOURCE_FILE:607)>
>
> would instead produce "boo!", as (qqq) would be expanded to if and
> then (if (even? 42) "boo!") would be parsed and discovered to be an if
> special form.

I think your macro (qqq) is being expanded to if: it's right there in
the error message. The parsing of (if (even? 42) "boo!" as a special
form cannot occur because the processing is past the opening paren;
macroexpanding the first element won't produce the re-evaluation of
the form as a whole, which is the only case where the 'if' is
recognized as the start of a special form. I find it easier to think
of special forms and not special symbols.

>
> On the other hand,
>
> user=> (quote (qqq))
> (qqq)
>
> seems to indicate that nothing is macroexpanded before special form
> parsing occurs, or it would have output if instead of (qqq), unless
> quote it another special case.

Well, quote is a special form, of course. I'd think that special forms
can happen after macroexpansion, as is the case when a macro produces
a conditional.

-- 
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