Can the D compiler detect final and optimize?
IGotD-
nise at nise.com
Fri Mar 13 15:08:34 UTC 2020
A little bit related to that some want class methods to be final
by default just like in C++. If I'm not mistaken one benefit of
final as default is that the compiler will insert hard coded
branches to the method as well as the possibility to do inlining.
Are my assumptions correct?
Instead of having final as default, can't the compiler itself
infer when a class is implicitly final and do the optimizations
itself? Benefits would be that a programmer has the possibility
to extend about all classes (in C++ would only be possible if
class author makes all methods virtual). The final keyword would
just mean that a class method is not allowed to be overridden.
Is this possible at all?
More information about the Digitalmars-d
mailing list