3 ms·
Probably because they don't want people talking cross-purposes or confusing their proposals with what is implemented in other languages, as they call out in the
by jsty 7y ago
Probably because they don't want people talking cross-purposes or confusing their proposals with what is implemented in other languages, as they call out in the intro:
"As the term generic is widely used in the Go community, we will use it below as a shorthand to mean a function or type that takes type parameters. Don't confuse the term generic as used in this design with the same term in other languages like C++, C#, Java, or Rust; they have similarities but are not the same."
- iainmerrick 7y agoThose four languages all have completely different implementations of parameterized types, but calling them all “generics” doesn’t add any extra confusion. To the contrary, it’s actually helpful to use the same word for something with roughly the same uses (eg generic type-safe container classes) even if the details are very different.
- jsty 7y agoI don't particularly disagree. My point was more that given what the authors wrote in the quoted sentence, I thought that - rightly or wrongly - was likely the reasoning behind the naming decision.
- nemith 7y agoContract is just the feature is defines the abilities of the genericized types. A contract in Go enables generic programming or as other state it "generics". In C++20 there is concepts which is very similar. https://en.wikipedia.org/wiki/Concepts_(C%2B%2B) https://en.wikipedia.org/wiki/Concepts_(C%2B%2B) in constraining the generic type before template expansion.
- pjmlp 7y agoContracts in programming language have a very precise meaning. https://en.wikipedia.org/wiki/Design_by_contract https://en.wikipedia.org/wiki/Design_by_contract