ah I tricked myself... I used "~a" inside the macro instead of "~c" or "~cls" so back to still impossible
=> (defmacro mew [cls & restt] (let [c cls] `(eval (new ~c ~@restt)) ) ) #'runtime.q/mew => (let [a java.lang.RuntimeException] (mew a) ) CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: a, compiling:(NO_SOURCE_PATH:2:3) => (defmacro mew [cls & restt] `(eval (new ~cls ~@restt)) ) #'runtime.q/mew => (let [a java.lang.RuntimeException] (mew a) ) CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: a, compiling:(NO_SOURCE_PATH:2:3) On Thu, Feb 14, 2013 at 10:58 PM, AtKaaZ <atk...@gmail.com> wrote: > ok looks like it's not impossible: > => *(defmacro mew [cls & restt] > (let [c a] > `(eval (new ~a ~@restt)) > ) > )* > > #'runtime.q/mew > => *(let [a java.lang.RuntimeException] > (mew a) > )* > #<RuntimeException java.lang.RuntimeException> > > > > On Thu, Feb 14, 2013 at 10:53 PM, AtKaaZ <atk...@gmail.com> wrote: > >> I figure since new is expecting a class at compiletime, we can never pass >> it a class that we evaluate at runtime(those locals), ergo => impossible to >> macro around "new" like that >> >> like this => impossible: >> *(let [a java.lang.RuntimeException] >> (macro-that-eventually-calls-new a))* >> >> maybe someone could suggest another way? clojure.reflect ? >> >> >> >> On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ <atk...@gmail.com> wrote: >> >>> thanks for the reply, >>> >>> => *(defmacro mew [cls & args] >>> `(new ~cls ~@args))* >>> #'runtime.q/mew >>> =>* (let [a java.lang.RuntimeException] >>> (mew a) >>> )* >>> >>> CompilerException java.lang.IllegalArgumentException: Unable to resolve >>> classname: a, compiling:(NO_SOURCE_PATH:2:3) >>> >>> that would be the equivalent macro of what *new* is doing >>> it's like >>> *(new a)* >>> CompilerException java.lang.IllegalArgumentException: Unable to resolve >>> classname: a, compiling:(NO_SOURCE_PATH:2:3) >>> >>> >>> This is the goal: >>> >>> The goal is to can write this form: >>> => *(let [a java.lang.RuntimeException] >>> (new a))* >>> >>> but I think it's impossible, at least by using "new" it is >>> >>> >>> On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut < >>> andy.finger...@gmail.com> wrote: >>> >>>> >>>> On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote: >>>> >>>> The goal is to can write this form: >>>> => *(let [a java.lang.RuntimeException] >>>> (new a) >>>> )* >>>> CompilerException java.lang.IllegalArgumentException: Unable to resolve >>>> classname: a, compiling:(NO_SOURCE_PATH:2:3) >>>> >>>> attempt with macro: >>>> =>* (defmacro mew [cls & restt] >>>> `(new ~(eval cls) ~@restt) >>>> )* >>>> #'runtime.q/mew >>>> >>>> >>>> This is probably your closest attempt. Try this variation on the above: >>>> >>>> (defmacro mew [cls & args] >>>> `(new ~cls ~@args)) >>>> >>>> user=> (macroexpand-1 '(mew java.lang.RuntimeException)) >>>> (new java.lang.RuntimeException) >>>> >>>> Andy >>>> >>>> -- >>>> -- >>>> 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. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Please correct me if I'm wrong or incomplete, >>> even if you think I'll subconsciously hate it. >>> >>> >> >> >> -- >> Please correct me if I'm wrong or incomplete, >> even if you think I'll subconsciously hate it. >> >> > > > -- > Please correct me if I'm wrong or incomplete, > even if you think I'll subconsciously hate it. > > -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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.