|
|
|
|
|
by staticint
3901 days ago
|
|
I imagine not that much in practice. It is not like someone is going to manually write out identical functions twenty times for each type they want to support. That's precisely what computers are good at doing and there are countless tools to do it painlessly. The bigger problem is that Go doesn't have type inheritance or similar. Meaning, there's no great way to say that this generic function will only work with number types, for example. You leave the burden on the programmer to ensure their generalized function is applied only to types which it is intended to be used with. While that is less than ideal, I cannot see that increasing developer time by a significant margin. |
|
I'll stop you right there. Have you seen a modern Go codebase?
They most certainly duplicate the simplest of functions, resort to `go generate`, or use reflection.