Tiago Antão wrote:
> Again, the point here is to be able to construct method names (full
> call signatures, really) on runtime.
>
> I am lost. As in newbie clueless :(
As others have suggested you need to use either Java's reflection or
Clojure's eval. Here's some examples:
Using reflection:
(let [obj "some string"
method (.getDeclaredMethod (class obj) "substring"
(into-array Class [Integer/TYPE]))]
(.invoke method obj (to-array [2])))
=> "me string"
If you want to know more about what you can do with reflection, consult:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html
Using eval (which will also work for dynamically calling Clojure functions):
(let [obj "some string"
fname ".substring"]
(eval (list (symbol fname) obj 2)))
=> "me string"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
-~----------~----~----~----~------~----~------~--~---