visibility vs. accessibility of protected symbols

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 17 14:03:40 PST 2012


On Friday, February 17, 2012 20:02:53 Timon Gehr wrote:
> I understand what NVI is. It is just that private methods
> overridable from a different module don't have many merits,
> regardless of how NVI is apparently sometimes implemented in C++.
> The fact that C++ has overridable private methods is quite likely
> just a side-effect of wanting to give some kind of semantics to a
> method declared as both private and virtual. I could argue that
> it sounds like you don't understand what NVI is because you
> assume C++'s private virtual semantics are required for the
> implementation of NVI. ;)

It's required if you implement NVI the way that's typical in C++ and the way 
that is requested in the NVI-related bug report.

You can get close enough to the same effect using protected, so it's arguably 
not necessary (which is one of the reasons that I'm arguing against making 
private virtual), but if we're talking about NVI in the traditional sense 
(which is what the bug report is looking for and TDPL indicates that you can 
do in its discussion on NVI), it _is_ required.

Fortunately, it looks like Andrei and Walter have agreed that private shouldn't
be made virtual, regardless what TDPL says - though what that means for NVI
and interfaces, I don't know. Protected may be enough in that case as well.

- Jonathan M Davis


More information about the Digitalmars-d mailing list