On Fri, Nov 21, 2008 at 03:38:01PM -0500, Stephen Wrobleski wrote: > Now, I can see a standard way of doing something like this > > (defmacro def-gen-class [name & options] > (let [{:keys [name bytecode]} > (eval `(gen-class ~(str name) [EMAIL PROTECTED]))] > (if *compile-files* > (.writeClassFile Compiler (.replace name "." "/") > bytecode) > (.. clojure.lang.RT ROOT_CLASSLOADER > (defineClass (str name) bytecode))) > > '(do))) > > (Haven't thought much about the proper phasing. But I used a macro so that > nothing is left around after compile-time) >
heh heh, that whole approach is terrible. I must have been thinking that eval has magical access to a macro's lexical environment. The best we can do seems to be to generate the class, and if its not already defined (presumably from AOT), either defineClass or writeClassFile based on *compile-files*. I don't think its possible to error out on an already defined class unless we can figure out that we're not in the initializer of an AOT compiled module. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---