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 <ja...@booleanknot.com > <javascript:>>: > >> On 18 October 2015 at 23:54, Timur <timur...@gmail.com <javascript:>> >> 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 >>> execute this method on this object through the symbol. >>> >>> For instance *(. obj sym)* throws an exception. Here symbol for >>> instance contains toString >>> >>> Any ideas about how I can do this? >>> >> >> eval is probably the most straightforward way to achieve this: >> >> (eval `(. ~obj ~sym)) >> >> I'm uncertain of the performance of this compared to using the Java >> reflection API, but it's a lot easier to write. >> >> - James >> >> -- >> 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/d/optout. >> > > > > -- > 庄晓丹 > Email: killm...@gmail.com <javascript:> xzh...@avos.com > <javascript:> > Site: http://fnil.net > Twitter: @killme2008 > > >
-- 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.