Looking at the proposal, operators are the reason that contracts are used rather than interfaces.
Why not use interfaces instead of contracts? > *The interface method syntax is familiar.* *Writing contract bodies > with x + x is ordinary Go syntax, but it* > *is stylized, repetitive, and looks weird.*It is unclear how to represent > operators using interface methods. We considered syntaxes like +(T, T) T, > but that is confusing and repetitive. Also, a minor point, but ==(T, T) > bool does not correspond to the == operator, which returns an untyped > boolean value, not bool. We also considered writing simply + or ==. That > seems to work but unfortunately the semicolon insertion rules require > writing a semicolon after each operator at the end of a line. Using > contracts that look like functions gives us a familiar syntax at the cost > of some repetition. These are not fatal problems, but they are difficulties. *https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md#why-not-use-interfaces-instead-of-contracts* <https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md#Why-not-put-type-parameters-on-packages> On Wednesday, October 10, 2018 at 5:14:35 PM UTC-4, Ian Denhardt wrote: > > I've seen a lot of folks expressing the sentiment "we should just use > interfaces instead of this new contract thing." Most of the discussion > I've seen around this jumps right to operator overloading without being > terribly explicit about the general case; I've written a proposal > focusing on the latter: > > https://gist.github.com/zenhack/ad508d08c72fce6df945a49945ad826d > > (It is also linked from the feedback wiki page). > > It punts on operator overloading, though discusses some related > subtleties. > > Thoughts? > > -Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.