Re:The Updated Draft Design for Go 2 Contracts
by Animats on Saturday July 27, 2019 @03:17PM
(#20543612)
Why are these called "contracts"? It's just another generic type mechanism. "Contracts" are generally associated with entry and exit conditions for functions, and are not confined to single variables. A real contract looks like:
[ Parent
| on HN ]
Re:The Updated Draft Design for Go 2 Contracts
by Matthias247 on Saturday July 27, 2019 @05:36PM
(#20544338)
Why not? They certainly define contracts for the type - at least that's my non-native speaker understanding of the english word.
It might seem weird if one used a different programming language which used the term for a slightly different concept - but that doesn't mean Go's usage is bad.
The concept is similar to what concepts are in C++ and traits in Rust. And from those terms I actually find contract to be the most understandable for people who are new to these things.
Re:The Updated Draft Design for Go 2 Contracts
by sseth on Saturday July 27, 2019 @04:54PM
(#20544130)
The terminology comes from a proposal for C++ which has been under discussion for a long time.
Re:The Updated Draft Design for Go 2 Contracts
by detaro on Saturday July 27, 2019 @05:25PM
(#20544276)
C++ contracts are what Animats describes. Constraints and concepts are more like what's described in the article: https://en.cppreference.com/w/cpp/language/constraints
Re:The Updated Draft Design for Go 2 Contracts
by Animats on Sunday July 28, 2019 @04:08AM
(#20546403)
"Contract" terminology is from Eiffel, from 1986.[1]
Re:The Updated Draft Design for Go 2 Contracts
by apta on Saturday July 27, 2019 @10:17PM
(#20545503)
They want to avoid the term "generics" or "traits", same as how they avoided the word "exception" when they implemented "panic". golang likes to reinvent the wheel and call it something else just for the sake of it.
Re:The Updated Draft Design for Go 2 Contracts
by Animats on Sunday July 28, 2019 @04:01AM
(#20546384)
"When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean—neither more nor less." "The question is," said Alice, "whether you can make words mean so many different things." "The question is," said Humpty Dumpty, "which is to be master—that's all."