private is non-virtual: Stuck in C++-thinking?

deadalnix deadalnix at gmail.com
Tue Oct 23 12:34:35 PDT 2012


Le 20/10/2012 01:14, Jonathan M Davis a écrit :
> On Friday, October 19, 2012 23:22:26 monarch_dodra wrote:
>> According to TDPL, this should be legal. In particular, there is
>> an entire section about it regarding NVI.
>>
>> No idea what it going on, but I'm curious for answers.
>
> For interfaces, where it's doing something to specifically enable NVI. It never
> says that for classes.
>
> It's been discussed a number of times before, and I think that it's fairly
> clear that Walter has no intention of changing it. Regardless, it would
> actually be a _huge_ problem for private to be virtual, and it's completely
> unnecessary for NVI (protected does the job just fine). If private were
> virtual, then it that would kill inlining and any other optimization relying
> on knowing the body of the function or anything else which gets affected by a
> function being virtual - including the cost of the vtable lookup.

Yes, if you don't want that, just define this a a private free function. 
D isn't some kind of language where everything need to be an object.


More information about the Digitalmars-d mailing list