--- Comment #9 from Jonathan M Davis <> 2011-03-01 16:08:37 
PST ---
Final says that a function can't be overridden. That doesn't necessarily make
it non-virtual. For instance, if that function is already overriding another
function, then final isn't going to make it non-virtual. It does give you some
indirect control over whether a function is virtual or not, but it's not quite
the same thing. Really, final is intended for preventing overiding, not for
making a function non-virtual. It just does that as an optimization, because it
knows that it can. You don't explicitly have control over whether a function is
virtual or not.

Regardless, the fact that the only way to make a function non-virtual (assuming
that private is overridable) is if you specifically mark it is a final means
that most private functions _will_ be virtual and will _not_ be inlinable,
because the average programmer won't realize that they have to do that to make
the function inlinable. So, it's going to be a definite performance hit if
private becomes overridable. It makes the default inefficient for essentially
no gain. You can still do NVI with protected, so the only real reason IMO to
make private overridable is simply because TDPL said that you could in its
discussion of NVI. I think that it would be better in this case to fix TDPL
than change dmd. Otherwise, the cost in efficiency is too high for essentially
no gain.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to