Re: Generating a class with a macro

2009-12-27 Thread Michel Vollebregt
That is a very clear explanation. Thanks! -- 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 unsubs

Re: Generating a class with a macro

2009-12-27 Thread kreso
> 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

Re: Generating a class with a macro

2009-12-27 Thread Michel Vollebregt
Hmm... seems you're right. If I fix the name of the post-init method, instead of using a gensym, it works. (Actually, that was exactly what I was doing to get the two-macro-version working). Still I don't really understand WHY the gensym is called at different times. Is this a special case when yo

Re: Generating a class with a macro

2009-12-27 Thread kreso
Hi, Try changing the name of your post-init function to something like (symbol (str (name cname "-post-init"))), maybe your problem is that gensym generates different symbols at runtime. -- Krešimir Šojat -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Generating a class with a macro

2009-12-26 Thread Michel Vollebregt
I think I have an interesting problem. I'm trying to create a macro that generates a class AND a post-init method for the class. Something like: ;;; create the macro (defmacro definstance [name & body] (let [post-init (gensym "postinit")] `(do (defn ~(symbol (str "-" post-init)) [this