Devirtualization and Static Polymorphism
9 points by noncrab
9 points by noncrab
I wonder if there are languages that (in the whole program case) are able to detect all (instanced) derived classes and somehow convert the virtual dispatch to a struct flag + if tree. This would give the performance of using enums instead of vtables while keeping the extensibility of derived classes.
I think that in most cases if you have whole program understanding you can resolve a call to just a few cases. I can't think of a counter example, maybe if you have generics the situation is a bit more complicated but still one can monomorphize everything as Rust (or Julia).