Re:Golang generics proposal has been accepted
by cies on Wednesday February 10, 2021 @03:55PM
(#26094653)
Really? Why then there's List.map, Maybe.map, Array.map, and I have to select one of them? Is that not what generics would fix?
[ Parent
| on HN ]
Re:Golang generics proposal has been accepted
by sdfsfsf3kjdf on Wednesday February 10, 2021 @04:01PM
(#26094744)
> Is that not what generics would fix?
No. That would be fixed by having something akin to typeclasses, traits or interfaces.
Elm's List, Maybe and Array are all defined using a generic type parameter.
Re:Golang generics proposal has been accepted
by shakow on Wednesday February 10, 2021 @07:10PM
(#26096591)
No, it fixes that you don't have to chose between ListOfInts, ListOfStrings and ListOfListOfArrayOfInt.
BTW, one doesn't have to chose between them in Go either, but only because there are under-the-hood generics for the native types, that are only accessible to the language designers.
Re:Golang generics proposal has been accepted
by floxy on Wednesday February 10, 2021 @05:46PM
(#26095861)
There is a terminology issue here, with "generic" being overloaded to mean different things. Parametric polymorphism is what Go is adding. You'd like to see something like ad hoc polymorphism in Elm, like type-classes in Haskell. But neither of those should be confused with the datatype generic programming.
https://en.wikipedia.org/wiki/Parametric_polymorphism