On Sun, Apr 28, 2024 at 4:10 AM Andrew Harris <harris...@spu.edu> wrote: > > 1. Tuple types > Outside of generics, tuple type syntax requires named fields. > > TupleType = "(" { IdentifierList Type [ ", " ] } ")" . > > // e.g.: > type Point (X, Y int) > > More irregularly, the TupleType syntax is used exclusively to declare named > types, and these named tuple types cannot implement methods. As a result, a > named tuple type is entirely defined at the site of the type definition.
Thanks for writing this up. This part of what you wrote seems too similar to a struct. I don't know whether we will ever add tuples to Go, but I'm certain that if we add them they must be clearly distinct from structs. If people ever start wondering "should I use a struct or should I use a tuple," then we have failed. One of the goals of Go is that it should be a simple language. One of the characteristics of a simple language is that people spend their time writing code. They don't spend their time considering which aspects of a language to use and how. Go is also intended to be an orthogonal language. That means that a concept should apply wherever it is meaningful. In particular, in Go, any named type should be permitted to have methods. To add a restriction saying that certain kinds of types can't have methods is to complicate the language and means that people have more to remember. Thanks. 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/CAOyqgcWuiBPhj%3D8wsXWXRKz6%2BdW%3D1jdLQObkc93GOiY5Hwg_3Q%40mail.gmail.com.