virtual-by-default rant

F i L witte2008 at gmail.com
Sat Mar 17 19:47:53 PDT 2012


I'm a bit confused. Reading through the virtual function's docs 
(http://dlang.org/function.html#virtual-functions) it says:

"All non-static non-private non-template member functions are 
virtual. This may sound inefficient, but since the D compiler 
knows all of the class hierarchy when generating code, all 
functions that are not overridden can be optimized to be 
non-virtual."

So if all functions are automatically optimized to non-virtual 
where applicable, then the "final" keyword is for conceptual 
access limitation only. This makes a lot of sense to me. Is there 
something I'm not getting that makes you want an explicit 
"virtual" keyword?


More information about the Digitalmars-d mailing list