You need to know something... it's a dialect of LISP, the only limitation 
is you.

On Thursday, February 14, 2013 5:08:57 PM UTC-5, AtKaaZ wrote:
>
> Thank you! I didn't know you could do .newInstance
>
> oh that's a nice trick with eval and list 'new
>
> So it's not impossible after all, thanks Aaron!
> Here's what I got from what you said:
> => *(defmacro mew [cls & restt]
>        `(eval (list 'new ~cls ~@restt))
>      )*
> #'runtime.q/mew
> => *(let [a java.lang.RuntimeException]
>        (mew a)
>      )*
> #<RuntimeException java.lang.RuntimeException>
>
> it makes sense now, using eval at runtime not at compile time as I was 
> trying
>
> and also the newInstance variant:
> => *(defmacro mew [cls & restt]
>        `(.newInstance ~cls ~@restt)
>      )*
> #'runtime.q/mew
> => *(let [a java.lang.RuntimeException]
>        (mew a)
>      )*
> #<RuntimeException java.lang.RuntimeException>
>
>
> Really, thank you Aaron, 
>
>
> On Thu, Feb 14, 2013 at 11:02 PM, Aaron Cohen 
> <aa...@assonance.org<javascript:>
> > wrote:
>
>> Yes, since this is runtime you should use reflection.
>>
>> (let [a java.lang.RuntimeException]
>>    (.newInstance a))
>>
>> Alternatively, you can use eval:
>>
>> (let [a java.lang.RuntimeException]
>>   (eval (list 'new a)))
>>
>>
>> On Thu, Feb 14, 2013 at 4:53 PM, AtKaaZ <atk...@gmail.com 
>> <javascript:>>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 <javascript:>
>>> > 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.fi...@gmail.com<javascript:>
>>>> > 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 clo...@googlegroups.com<javascript:>
>>>>> Note that posts from new members are moderated - please be patient 
>>>>> with your first post.
>>>>> To unsubscribe from this group, send email to
>>>>> clojure+u...@googlegroups.com <javascript:>
>>>>> 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+u...@googlegroups.com <javascript:>.
>>>>> 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.
>>>
>>>  -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com <javascript:>
>>> 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+u...@googlegroups.com <javascript:>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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+u...@googlegroups.com <javascript:>.
>> 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.
>
>  

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