> Still I don't really understand WHY the gensym is called at different
> times. Is this a special case when you use genclass in a macro? Or
> should I be aware of other cases too?

What happens is that gen-class (and gen-interface) macroes don't
expand to anything (nil to be exact), but they have side effect as
they generate java bytecode and save them in appropriate files while
expanding and *compile-files* flag is set to true. This is not
something you want to do but in this special case it is requred for
them to behave this way.

So you create unique symbol 'g1 at compile time (or at bytecode
generation time if that is more precise for this situation) that is
used for both your var name and as a argument to :post-init, but at
the runtime your macro is expanded again generating new 'g2 and your
post-init function is assigned to it while gen-class ignores the
second expansion as *compile-files* is set to false and you load
bytcode generated from the time when gensym generated 'g1. It works
from time to time because gensym can generate the same unique symbol
in different processes.

--
Krešimir Šojat

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