visibility vs. accessibility of protected symbols

Jonathan M Davis jmdavisProg at gmx.com
Mon Feb 13 15:26:14 PST 2012


On Tuesday, February 14, 2012 00:15:40 Martin Nowak wrote:
> Can you elaborate on what issues you see with NVI. After all it's only the
> final public
> method that needs to call the virtual private methods.

As I explain in that bug report, NVI can be acheived with protected rather 
than private. So, we can do NVI now with private being non-virtual. However, 
if we make private virtual, then the compiler can no longer inline private 
functions in classes unless they're marked as final. That's a performance hit 
to pretty much every class ever written.

Yes, the conscientious programmer will mark their classes' private functions 
final unless they intend to use them for NVI, but the _default_ is then 
inefficient for little to no gain. All you gain is the ability to do NVI with 
private instead of protected, and that is not even vaguely worth the 
performance hit to almost every D class ever IMHO.

- Jonathan M Davis


More information about the Digitalmars-d mailing list