Re: [go-nuts] tuples! tuples! tuples!

2024-04-30 Thread Andrew Harris
*func main() {for x := range FSeq(strconv.Atoi) { fmt.Println(reflect.TypeOf(x))}}func FSeq[V (... any)](f func(string) V) iter.Seq[V] {return func(yield func(v V) bool)) { yield(f("1234"))}}* *>>> If it wouldn't

Re: [go-nuts] tuples! tuples! tuples!

2024-04-30 Thread roger peppe
On Mon, 29 Apr 2024 at 22:06, Andrew Harris wrote: > 2. On implementation, before considering variadic tuple constraints: There > is tuple machinery already in the type system > , used > for assignments and signatures, but tuples

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread Andrew Harris
*> FWIW this kind of restriction has no precedent in Go. Currently any type may be unnamed. This restriction seems arbitrary and irregular to me. * It seems unpopular. *> Isn't this illegal according to your TupleType syntax above? * Further evidence of a wrong idea :) *>> [T (any, any)]

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread roger peppe
On Sun, 28 Apr 2024 at 12:10, Andrew Harris wrote: > Bouncing out from some recent discussions on the github issue tracker, it > seems like there's some interest in tuples in Go. I thought the discussion > in #66651 led to some interesting ideas, but it's also beginning to drift. > Maybe this is

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread Andrew Harris
Brian: 1: There would be no access to implicitly typed tuple elements. Both implicit and named tuple values would expand with `...`, for example in an assignment like `x, y := (0, 0)...`. (FWIW, #64457 suggested decimal names for tuple elements `.0`, `.1` etc.) 2: #64457 and #66651 revealed

Re: [go-nuts] tuples! tuples! tuples!

2024-04-28 Thread roger peppe
I agree with Ian that the named field syntax is too close to structs. For me, tuples start to make sense in Go mainly because they map directly to and from the tuple-like values we already pass to and from functions, and specifically in the context of a variadic type parameter language feature

Re: [go-nuts] tuples! tuples! tuples!

2024-04-28 Thread Ian Lance Taylor
On Sun, Apr 28, 2024 at 4:10 AM Andrew Harris 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

[go-nuts] tuples! tuples! tuples!

2024-04-28 Thread Andrew Harris
Bouncing out from some recent discussions on the github issue tracker, it seems like there's some interest in tuples in Go. I thought the discussion in #66651 led to some interesting ideas, but it's also beginning to drift. Maybe this is a better place to brain-dump some ideas. (This could be a