Re:Maybe adding generics to Go is about syntax after all
by djur on Tuesday September 04, 2018 @11:18AM
(#17909611)
Using macros to implement generics has the same problem that C++ templates have, which is described in the Go 2 generics proposal: it's difficult to provide clear error messages for developers in many cases. Functions parameterized on a single type are the easy problem to solve. Where things get thorny is when you parameterize on multiple types with various constraints and/or have some kind of interaction in the function body. The goal of the Go 2 generics contracts (and C++ concepts, Haskell typeclasses, Rust traits, etc.) is to make those expectations explicit.
[ Parent
| on HN ]
Re:Maybe adding generics to Go is about syntax after all
by slavapestov on Tuesday September 04, 2018 @06:24PM
(#17913384)
Macros and C++ templates are also incompatible with separate compilation which leads to increased compile times and binary bloat.