visibility vs. accessibility of protected symbols
timon.gehr at gmx.ch
Mon Feb 13 15:36:31 PST 2012
On 02/14/2012 12:26 AM, Jonathan M Davis wrote:
> 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
Virtual private does not allow for cross-module NVI, so what would be
the point anyway?
More information about the Digitalmars-d