From: Eric Mahurin Date: 2005-08-30T18:05:51+09:00 Subject: Re: Method behaves differently when called using #send --- Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Method behaves differently when called using > #send" > on Tue, 30 Aug 2005 01:03:12 +0900, Yukihiro Matsumoto > writes: > > |Because I felt they are different, as I said above. I admit > fcall is > |not the best name, but very few people would use it. > > OK, here's another idea. How about > > foo.send(:bar) > > calls only public methods and > > send(:bar) > > calls private methods of the receiver as well? > > matz. Here is my 2 cents based on my usage -- * For almost every case I use #send/#__send__, I use it to bypass encapsulation to call a protected/private method. The above would force me to use #instance_eval instead. To me #instance_eval seems a little more "dangerous" because it allows me easy access to everything within the object whereas the current #send just gives me private methods. Of course private method access allows you to do about anything too... * For cases where I want to call a variable method, I use #method to get a method object and Method#call later on it (usually many times). I do it this way because intuitively it seems more efficient - do the method name lookup only once, but with the current implementation I don't think it makes much difference (compared to using #send). Currently, #method looks up public/protected/private methods. If you are considering making changes along these lines, I think #method should take an optional arg include_private=false, just like #respond_to? does. So for me, if you make #send (and #__send__?) only call public methods it will break almost every place I use it (not very many). I don't think making a change like this is necessarily bad, but just realize that many uses of #send is to be able access private/protected methods, so those will be broken. ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs