3 ms·
> As auto-generated it can support more features than even an advanced generics could provide. No, it can't. There are patterns that no monomorphization strate
by pcwalton 11y ago
> As auto-generated it can support more features than even an advanced generics could provide.
No, it can't. There are patterns that no monomorphization strategy (including code generation) can express. For example:
func MakeList<T>(x T) List<T> {
...
}
func Foo<T>(x T) {
if ... {
Foo(MakeList(x))
}
}
This is a contrived example, but this shows up from time to time in functional data structures.
- fpoling 11y agoCode generation can do type erasure starting, for example from List<List<SomeConcreteType>>.