On Sun, 04 Dec 2016 10:36:30 +0000, angel wrote: > IMHO it was always obvious that the proper way is "devirtualization" > within compiler optimization process.
Incremental compilation. You can't in general do this in the compiler. * I write a library that uses std.socket:InternetHost. * You compile it into libawesome.a. The compiler must use virtual dispatch (you might override members elsewhere). * You write an app that uses libawesome. * You compile it all together. Only now does the compiler know it can use static dispatch -- but it's too late; libawesome.a was already compiled. That's why this is a *link* time optimization. You can get around this by only doing whole program compilation, but that can be slow. You *could* have a compiler flag that enables whole-program compilation and associated optimizations, but if you can do it faster at link time, that's better. What you test with should be as close to what you ship with as possible, and the longer the optimization step is, the more likely it is that I'll turn it off while developing. > From the developer's POV, the > correct semantics is when each method is virtual. Assuming the developer made the function final for speed and not to indicate that this function should not be overridden.
