virtual, package, private

Robert jfanatiker at gmx.at
Tue Jun 18 02:47:58 PDT 2013


On Tue, 2013-06-18 at 10:34 +0200, Paulo Pinto wrote:
> If a method is supposed to be overridable by others but not 
> visible outside of the class that is what protected is for.

It is like protected, but restricts it to classes in the current module.
This is useful at times, if you have a well known hierarchy that should
not be extended by third parties.

Whether this is good design or not, is debatable, I had some use cases
where it made sense for me. Regardless, I don't see why the language
should disallow it, except for performance reasons because virtual is
the default. If this default is changed, I really see no reasons to
disallow it.



More information about the Digitalmars-d mailing list