4 ms·
> Erasure, BTW, is a pretty standard strategy. Even Haskell does not distinguish at runtime between List Int and List String. Haskell doesn't do overloading an
by unscaled 4y ago
> Erasure, BTW, is a pretty standard strategy. Even Haskell does not distinguish at runtime between List Int and List String.
Haskell doesn't do overloading and reflection, so for Haskell type erasure is a pure implementation detail. It doesn't leak out to the programmer.
- pron 4y agoYes, which is why in Java the cost isn't free but it's still rather low. Of course, the calculus has changed due to memory hierarchies, which is why Valhalla brings with it specialisation for value types (that outweighs the benefits of erasure for those types, but they're not variant, so it doesn't require baking a variance model into the VM).