From: dblack@... Date: 2006-02-15T10:13:21+09:00 Subject: Re: Private methods - only available to oneself? --8323328-1467733335-1139965983=:18344 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1467733335-1139965983=:18344" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1467733335-1139965983=:18344 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Wed, 15 Feb 2006, Minkoo Seo wrote: > David Vallner wrote: >> Dna Utorok 14 Febru=E1r 2006 01:08 Adam P. Jenkins nap=EDsal: >>> So I don't see the point of drawing the protection boundary >>> around *instances* of the class, rather than the code which implements >>> the class. >>> >> >> And I don't see the point of drawing a restriction in Java's private / >> protected smack-dab across an inheritance hierarchy. I accuse the whole >> thread of having degenerated into pure religion. >> > > Private/protected meaning of Ruby is unique, and I believe some kind of > elaboration on that point is needed. What method is accessible from the > outer space is quite important in learning a language, isn't it? > > Let me put this way. On one hand, ruby allows me to redefine or add > methods to a class which I've not defined. Also, it is possible to > redefine or add methods to a instance of class. Subclasses can access > parent classes. Moreover, there's no notion of 'final(Java)/sealed(C#)' > class in ruby. From this point of view, ruby's objects are quite > dynamic because they can be changed anytime. If these are the only > characteristics in ruby, I would just happy with it. > > However, on the other hand, ruby does not allow an instance to access > other instance even if they are the instance of the same class. In this > case, an object is something that can not be easily accessed. > > I feel that these two conflict, and need justification. There's no contradiction or conflict between the dynamism of Ruby and the existence of the (largely advisory) "private" access level. You can always get an object to call a private method (with send), or even open up the class and change the access level. In other words, the private status of a method can also be changed anytime, just like the other things you've mentioned. (I don't know why one would do it, but one could.) David --=20 David A. Black (dblack@wobblini.net) Ruby Power and Light (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black --8323328-1467733335-1139965983=:18344-- --8323328-1467733335-1139965983=:18344--