logoalt Hacker News

branko_dyesterday at 9:04 PM1 replyview on HN

On the other hand, if the compiler can prove at compile-time what type the object must have at run-time, it can eliminate the dynamic dispatch and effectively re-enable inlining.


Replies

MarsIronPIyesterday at 10:16 PM

Which is why runtime polymorphism in Rust is very hard to do. The its focus on zero-cost abstractions means that the natural way to write polymorphic code is compiled (and must be compiled) to static dispatch.