On Mon, Aug 3, 2009 at 8:53 AM, Mike DeLaurentis <delauren...@gmail.com>wrote:
> > I believe it stands for "member function". From the doc string: > > "Expands into code that creates a fn that expects to be passed an > object and any args and calls the named instance method on the > object passing the args. Use when you want to treat a Java method as > a first-class fn." Interestingly, it's just a very simple macro to automate wrapping the method call in an anonymous lambda: user=> (macroexpand-1 '(memfn add x y)) (clojure.core/fn [target__4193__auto__ x y] (. target__4193__auto__ (add x y))) That is, basically (fn [object x y] (.add object x y)). I'd guessed as much even before trying the above macroexpand-1 line. It was the obvious way to implement it with no magic required. (I think you'll find that most of the magic in Clojure is ClassLoader voodoo quite far under the hood, and that a lot of seemingly fancy features are simply implemented as fairly basic macros. The ".add" type of method call, however, does seem to be some sort of serious mojo. (doc .add) throws an exception rather than recognizing it as a special form or similarly, though you also get strange errors if you try to use .add as a variable name.) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---