4 ms·
Well, parametric polymorphism in the case of go would probably just be a performance optimisation over function taking interface as parameter, right ? i usuall
by bsaul 7y ago
Well, parametric polymorphism in the case of go would probably just be a performance optimisation over function taking interface as parameter, right ?
i usually see monsters when you combine generics with objects and inheritence, but you're right that since go also doesn't provide those...
i think when talking about generics in go we also mean struct accepting generic components. Not just functions
- wtetzner 7y agoSure, and I still don't really see a problem with it. Yes, it makes the compiler more complex, but I can't think of any ways it could be abused more than the existing language features. And it would make a lot of programs written in Go simpler.
- bsaul 7y agoBecause go is very used in data plumbing code, i found that many functions can actually work fine at the byte array level, and that it leads to a better design. It would be very tempting with proper generic support to try to have every function work with the topmost types, just because we assume it provides more type safety. I could imagine a struct representing a "User" byte array, or other atrocities.