Re: Calling object members with symbols

2015-10-19 Thread Timur
Thanks for the answers! On Monday, October 19, 2015 at 3:15:16 AM UTC+2, dennis wrote: > > In such case you have to use `eval`, another post > > https://groups.google.com/forum/#!topic/clojure/YJNRnGXLr2I > > 2015-10-19 9:10 GMT+08:00 James Reeves >: > >> On 18 October

Re: Calling object members with symbols

2015-10-18 Thread dennis zhuang
In such case you have to use `eval`, another post https://groups.google.com/forum/#!topic/clojure/YJNRnGXLr2I 2015-10-19 9:10 GMT+08:00 James Reeves : > On 18 October 2015 at 23:54, Timur wrote: > >> Hi all, >> >> Is there anyway to call an object

Calling object members with symbols

2015-10-18 Thread Timur
Hi all, Is there anyway to call an object member using its symbol? For instance we have an object o, we get the symbol of a method, e.g., toString, of our object o using clojure.reflect/reflect and and I want to execute this method on this object through the symbol. For instance *(. obj

Re: Calling object members with symbols

2015-10-18 Thread Michael Blume
Nope, still won't work. (let [s 'toString] (invoke 1 s)) java.lang.IllegalArgumentException: No matching field found: s for class java.lang.Long On Sun, Oct 18, 2015 at 5:51 PM dennis zhuang wrote: > You may have to use macro: > > user=> (defmacro invoke [obj sym] `(.

Re: Calling object members with symbols

2015-10-18 Thread dennis zhuang
You may have to use macro: user=> (defmacro invoke [obj sym] `(. ~obj ~sym)) #'user/invoke user=> (invoke 1 toString) "1" 2015-10-19 6:54 GMT+08:00 Timur : > Hi all, > > Is there anyway to call an object member using its symbol? > > For instance we have an object o, we get

Re: Calling object members with symbols

2015-10-18 Thread James Reeves
On 18 October 2015 at 23:54, Timur wrote: > Hi all, > > Is there anyway to call an object member using its symbol? > > For instance we have an object o, we get the symbol of a method, e.g., > toString, of our object o using clojure.reflect/reflect and and I want to >