On Tuesday, 9 April 2013 at 03:09:09 UTC, Rob T wrote:
My understanding of this is that while all of your class functions will be virtual by default, the compiler will reduce them to non-virtual unless you actually override them, and to override by mistake is difficult because you have to specify the "override" keyword to avoid a compiler error.

I'd like to see that understanding confirmed as it was only implied in here:
http://dlang.org/overview.html

For extra safety you have to specify "final" which would be a pain if that's what you want by default, but I'm not so sure it's really necessary if the compiler really does optimize virtual functions away.

BTW, the red code/green code concept sounds like the most promising route towards a generalized solution. I'll try and find the time to watch it as well.

--rt

Slightly other way around. "override" only makes sure that you have something to override. You can omit it and virtual dispatch will still happen with no error. Error happens only when you mark with override method which does not exist in base class / interface.

"virtuality" can be optimized away from final methods and for symbols that don't get exposed for linkage (so that compiler can check all sources and verify that no override happens). It is not done in dmd currently, of course.

Reply via email to