On Mar 8, 2010, at 11:20 PM, Michał Marczyk wrote: > It's simple to write this way... And if you provide type hints, I'd > expect the resulting function to be quite performant. If you don't > care about that, here's a flexible alternative using eval: > > user> (defmacro methodfn [name] > `(fn [& args#] > (apply > (eval (concat (list '~`memfn '~name) > (map (fn [~'_] (gensym)) (rest args#)))) > args#))) > #'user/methodfn > user> ((methodfn substring) "asdf" 1) > "sdf" > user> ((methodfn substring) "asdf" 1 3) > "sd"
Thanks for the suggestion! I'm a little surprised that Clojure would adopt an awkward API purely for performance reasons, but I guess the beauty of Lisp is that I can fix it myself. -- 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