From: Sean O'Halpin Date: 2006-07-08T19:08:12+09:00 Subject: Re: About 1.9 #__method__ feature. On 7/8/06, Logan Capaldo wrote: > > On Jul 7, 2006, at 12:43 PM, Sean O'Halpin wrote: > > > On 7/7/06, dblack@wobblini.net wrote: > >> Hi -- > >> > >> On Fri, 7 Jul 2006, ara.t.howard@noaa.gov wrote: > >> > >> > On Fri, 7 Jul 2006, Logan Capaldo wrote: > >> > > >> >> Steal another name from lisp? > >> >> > >> >> obj.apply(:meth, 1, 2, 3) > >> >> > >> >> It's not send, but it's not funcall either. > >> >> > >> >> obj apply your :meth function to the arguments 1,2,3 > >> >> > >> >> Just throwing stuff out there, feel free to ignore me :) > >> > > >> > i was just about to suggest that name. still, there is nothing > >> which implies > >> > are receiverless context sensitive call that can access private > >> methods with > >> > that name is there? > >> > >> No -- which is why I like it much more than 'funcall' and > >> such :-) It > >> doesn't introduce the criterion of "receiverlessness" into a > >> situation > >> where the concept of having or not having a receiver isn't relevant. > >> > >> > >> David > >> > > > > FWIW, I'm already using apply, i.e.: > > > > module Enumerable > > def apply(&block) > > map {|i| i.instance_eval(&block) } > > end > > end > > > > which seems more in keeping with its meaning in lisp (though not > > really the same). > > > > Regards, > > Sean > > > > I disagree, yours is not especially closer to the Lisp meaning of > apply. The only difference (AFAIK) between Lisp's funcall and Lisp's > apply is how the argument list is expressed: > > [1]> (funcall #'+ 1 2) > 3 > [2]> (apply #'+ '(1 2)) > 3 > > > > Of course this probably means we should have #funcall and #apply > > obj.funcall(:meth, 1, 2) > obj.apply(:meth, [1, 2]) > Don't forget lisp is receiverless ;) AFAIK apply is usually used to apply a lambda with arguments to a list. So I think of apply as being more like: module Enumerable def apply(*args, &block) map{|x| x.instance_exec(*args, &block)} end end But that's only my interpretation. Regards, Sean