A contract can include multiple type parameters: https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md#mutually-referential-type-parameters AIUI your syntax can't cover that. And FWIW, I find the syntax of contracts in the doc far less "magic" than yours, but YMMV of course.
On Fri, Aug 31, 2018 at 6:43 AM Manlio Perillo <manlio.peri...@gmail.com> wrote: > I just read the "official" proposal for Go2 generics and contracts. > The current proposal makes the function syntax more complex, and the > syntax for the contract is a bit magic. > > What about something like: > > > type stringer template > > contract (x stringer) { > var s string = x.String() > } > > func Stringify(s []stringer) (ret []string) { > for _, v := range s { > ret = append(ret, v.String()) > } > return ret > } > > instead of > > > contract stringer(x T) { > var s string = x.String() > } > > func Stringify(type T stringer)(s []T) (ret []string) { > for _, v := range s { > ret = append(ret, v.String()) > } > return ret > } > > > Thanks > Manlio > > -- > 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. > -- 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.