wow that's pretty epic! => (def f (call-fn "java.lang.String" "substring" "startpos" "endpos")) #'runtime.q/f => (f "abcdef" 2 4) "cd" => (f (str "123" "45") (+ 1 1) 4) "34"
Thank you Meikel On Tue, Feb 12, 2013 at 1:51 PM, Meikel Brandmeyer (kotarak) <m...@kotka.de>wrote: > Hi, > > if you want to resort to eval you can define your own function on the fly. > > (defn call-fn > [& args] > {:arglists ([class method & args])} > (let [o (gensym) > [class method & args] (map symbol args)] > (eval > `(fn [~o ~@args] > (. ~(with-meta o {:tag class}) > (~method ~@args)))))) > > user=> (set! *warn-on-reflection* true) > true > user=> (def f (call-fn "java.io.File" "renameTo" "dest")) > #'user/f > user=> (f (java.io.File. "foo") (java.io.File. "bar")) > false > > Kind regards > Meikel > > -- > -- > 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. > > > -- 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.