Zach Tellman writes:


 > I guess I'm confused, then.  You contrast "complete recursive

 > expansion" with what the compiler does, and then say it's recursive

 > prewalk expansion, which is exactly what the compiler does.  Can

 > you clarify the difference between what you're doing and what the

 > compiler does?



Here's an example:



   (defmacro foo [x]

     `(list ~x ~x))



   (defmacro bar [x]

     `[~x ~x])



Now let's work on the form



   (foo (bar 'baz))



Plain macroexpand returns



   (list (bar 'baz) (bar 'baz))



whereas tools.macro/mexpand-all gives



   (list ['baz 'baz] ['baz 'baz])



It does this by first calling macroexpand, so foo gets called exactly

as during Clojure compilation and returns



   (list (bar 'baz) (bar 'baz))



mexpand-all then goes through that form and expands the two subforms

(bar 'baz).



So mexpand-all does exactly what the compiler does, in particular it

calls the macros with exactly the same arguments. But the compiler

interleaves macro expansion with compilation, so it never gives you

access to the fully expanded but uncompiled form which is



   (list ['baz 'baz] ['baz 'baz])



Konrad

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to