2 ms·
> fortunately methods can't have type parameters. This is quite tricky to implement properly if the compiler doesn't do some form of specialization. (Basically
by titzer 5y ago
> fortunately methods can't have type parameters.
This is quite tricky to implement properly if the compiler doesn't do some form of specialization. (Basically, you need a different vtable entry for each instantiation of a generic method, or you need a runtime lookup to find it). But given that the Go compiler is doing complete specialization, I'm surprised they left this out.
Generic methods (on classes) are the way to emulate first-class polymorphism (roughly, passing around type constructors) without explicit support in the language. It's a limitation that will eventually catch up with you.
- svnpenn 5y ago> It's a limitation that will eventually catch up with you. Go worked fine without it for 10 years...