G
gwtmp01
That said, I do think that Ruby's decision to make private mean
"only accessible to oneself" as opposed to "only accessible to
class members" is debatable. In fact I don't see the point of it
from a practical point of view. It seems to me that the main
reasons for making methods private is advertise that a) they're
implementation details that may change without notice in new
versions of the class, and b) they may require inside knowledge of
the class's workings to use correctly. Both of these reasons would
be just as well served by allowing other instances of the same
class to access private members, so I don't see the point of the
extra restriction. Anyone?
Are you saying that the only visibility attributes should be public
vs. protected
as opposed to the current public/protected/private triumvirate?
One reason to support the distinction in Ruby is the existence of
singleton methods. It is possible for an instance to behave differently
than any other instance of the class and as such you might want to
support that different behavior by marking some methods as private.
Gary Wright