From: ara.t.howard@... Date: 2006-07-08T00:15:53+09:00 Subject: Re: About 1.9 #__method__ feature. On Fri, 7 Jul 2006 transfire@gmail.com wrote: > > Sean O'Halpin wrote: > >> How about instance_send (on analogy with instance_eval and instance_exec)? > > +1 > > Why make this more complex than it needs to be? #instance_send is > reasonably obvious, #fucncall is not at all and is only menaingful to > lispers and brings in a whole new set of concepts about "functional > style". consider: harp:~ > cat a.rb class Object def funcall(*a, &b) instance_eval{ send *a, &b } end alias_method 'instance_send', 'funcall' end module A private def A.m() p 42 end end module B private def B.m() p 'forty-two' end end A.funcall 'm' B.funcall 'm' A.instance_send 'm' B.instance_send 'm' harp:~ > ruby a.rb 42 "forty-two" 42 "forty-two" with funcall we can consider modules as namespaces, each of which defines an 'm' method and in whose context 'm' can be called. if you've been coding ruby for a while you can probably easily read over the A.instance_send 'm' B.instance_send 'm' lines. but to newbies, or even non-newbies, the 'modules are instances of a Module class which is a Class which is a Module which are both Objects' circular thinking makes it slightly less than intuitive as to the reason one can call 'instance' methods on modules or classes. the receiveless context sensitive paradigm, although a new concept, is orthoganal to public/private and instance/class/module and can be expained rather simply: if one does obj.funcall :meth, 42 it's __always__ like being 'inside' the object, which means in an instance method for instances and insides a class definition for classes, etc, and doing meth, 42 2 cts. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama