Comment

Comment by microtonal

You can only do that if you can prove that T will never have subclasses that are larger.

Only if generic type parameters are covariant, if type parameters are invariant, this is not a problem. I guess that most languages with subtypes use invariance by default.

Also, many languages that do generics through monomorphization do not support subclassing (Rust, Haskell, etc.).

no plugins,

Well, there is always the option of boxing collection elements. (E.g. by using Box in Rust.)

parent microtonal 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton