From: "David A. Black" Date: 2005-08-30T22:02:48+09:00 Subject: Re: Method behaves differently when called using #send Hi -- On Tue, 30 Aug 2005, Eric Mahurin wrote: > --- 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. > [...] > > 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 think Matz's suggestion above actually simplifies the picture. It would just make send a real programmatic equivalent of the dot operator: class C def m n # yes send(:n) # yes self.n # no self.send(:n) # no end def n end private n end c = C.new c.m # yes c.send(:m) # yes c.n # no c.send(:n) # no c.instance_eval { n } # yes c.instance_eval { send(:n) } # yes (Give or take dealing with the issues of =-methods one way or the other.) It would mean that bypassing a private method was no *easier* with send than without it, but still possible either way. David -- David A. Black dblack@wobblini.net