--- Eric Mahurin <eric_mahurin / yahoo.com> wrote: > --- Yukihiro Matsumoto <matz / ruby-lang.org> wrote: > > > Hi, > > > > In message "Re: Method behaves differently when called > using > > #send" > > on Tue, 30 Aug 2005 01:03:12 +0900, Yukihiro Matsumoto > > <matz / ruby-lang.org> 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. > > Doing this would make the semantics for calling Object#send > different from every other method call. Would these be two > different methods or one method that can somehow sense > whether > it was called with a receiver? Although I wouldn't endorse > overriding/redefining send, what would happen if one did so? > Or would the second form not be a method call and "send" be a > new keyword instead. Another option would be to introduce > local methods and the first Object#send would be the public > method and the second would be the local method. > > I think simply separate methods is a better choice than the > confusion/complexity of the above. It also preserves one of > the main functionalities of send - bypassing method > protection > (private/protected). I just thought of a few more scenarios that should be thought of with this proposal: class A; end a = A.new a.send(...) # no access to private methods a.send(:send,...) # ??? a.instance_eval{send(...)} # access private methods a.instance_eval{send(:send,...)} # ??? class A def send(m,*args) super end end a.send(...) # ??? a.instance_eval{send(...)} # ??? The functionality of these ??? cases doesn't seem obvious to me. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com