Macros won't work because they are expanded at compile-time. We want to
choose the method at runtime.

Thanks,
Ambrose

On Thu, May 21, 2015 at 9:02 AM, Keith Irwin <ke...@zentrope.com> wrote:

> Not sure if this helps, but:
>
> user => (eval (symbol "Math" "PI”))
> 3.141592653589793
>
> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s"
> (to-array ["adasd"])))
> “adasd"
>
> Maybe a macro of some sort?
>
> (defmacro invoke-static
>   [c meth & args]
>   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))
>
> user => (invoke-static "java.lang.String" "format" "the %s" (to-array
> ["foo"]))
> “the foo"
>
> user=> (invoke-static "System" "currentTimeMillis")
> 1432170076378
>
> That kind of thing?
>
> On May 20, 2015, at 4:54 PM, Pierre Thibault <pierre.thibau...@gmail.com>
> wrote:
>
> I gave it a try:
>
> (.. (class String) (getMethod "format" (into-array Class [String
> (Class/forName "[Ljava.lang.Object;")])))
>
> But I am unable to get the method. I gave up.
>
> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>>
>> Hi Laurens,
>>
>> My example was not very good. Here another one:
>>
>> (.format (first '(String)) "%s" "foo")
>>
>> Imagine String is obtained dynamically. I guess then I have to use Java
>> reflection to do a dynamic invocation. I guess I am confused because
>> classes in Java are not objects.
>>
>> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>>>
>>> Hi Pierre,
>>>
>>> On May 20, 2015, at 3:38 PM, Pierre Thibault <pierre.t...@gmail.com>
>>> wrote:
>>>
>>> I can do Math/PI put how can I access PI if Math is in a expression like
>>> '(Math) for example?
>>>
>>>
>>> Can you provide a more specific example? Math/PI is always Math/PI, it
>>> doesn’t change if you put it in a nested form/expression.
>>>
>>> hth
>>> lvh
>>>
>>> --
>>> 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
>>> 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
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
> --
> 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/d/optout.
>
>
>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to