On Sat, Jul 18, 2020 at 4:55 AM Markus Heukelom <markus.heuke...@gain.pro> wrote: > > Concerning the current generics proposal, was it every considered to not > allow type contracts at all? > > No type contracts would mean that generic functions can only use =, & on > variables of parametric types, as these are always available for all types. > Nothings else is allowed. > > This would remove the possibility to write generic mathematical functions, > for example. But it is simple and it already enables a lot of usefulness. Was > this considered too restrictive? > > Type contracts could optionally be added in a later stage, but at least at > that point we will have a larger body of generic code to work and test with. > > A bonus, disallowing all operations except assignment and address-taking > would maybe also stop abuse of templates in the name of "but it is more > efficient than interfaces" and "fancy coding syndromes".
I think that for a language like Go any generics implementation must permit people to write the functions Min and Max. The functions are trivial, but they are among the first that programmers accustomed to generics complain about in Go. 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcX7NSXZWMnY%2BwuFa8tQakun5t_QwLZUcijokX6b5KCT-g%40mail.gmail.com.