[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: protected fields in v200?

Matthew Flatt writes:
 > At Wed, 20 Mar 2002 15:29:48 -0500 (EST), Doug Orleans wrote:
 > > Is there a way to make "protected" fields using MzLib's class.ss
 > > module in v200?  That is, a field that is not public (can't be
 > > accessed with class-field-accessor) but can be accessed by subclasses?
 > > It looks like there isn't
 > That's correct; there's currently no support for "protected".
 > It would be easy to add, but I wonder whether it's useful. The
 > `define-local-member-name' form already lets a programmer manage names
 > with lexical scope. Any opinions?

Well, I was recently reading "Encapsulation and Inheritance in
Object-Oriented Programming Languages" by Alan Snyder from 1986:


Snyder argued that inheritance breaks encapsulation, unless the
language allows a class to provide different interfaces to its clients
and its subclasses.  To me that means that protected methods are
pretty useful.  Protected fields are less so, but if you allow public
fields you might as well allow protected fields too.