As I understand it, all member functions are virtual in D but the compiler is free to make functions non-virtual if it sees that they are never overridden.
What I'm not clear on is what happens when you compile a module in which member functions are not overridden and then import that module somewhere else where you override a member function. I don't think it re-compiles the original module. Does it simply assume that any member function with external linkage is virtual?
-
All D member functions are virtual by default. I don't think there's any compilers out there that actually make functions non-virtual as an optimization. You can do it manually though, by marking the class or the function as "final".
-
I believe FeepingCreature is correct, but in addition I think you can assume that such optimizations only will be considered by the compiler if it directly creates an executable from the sources.
-
FeepingCreature is mostly correct except for templated functions which cannot be made virtual.
0 comments:
Post a Comment