Re: [go-nuts] "yield" is backwards

2024-02-07 Thread mspre...@gmail.com
I see. I was thinking of it from the point of view of the author of this yield/consume function. From that party's perspective, this function expresses the consumption of the value, not its production. But since the new go lang feature will make that not an explicit function, that is not the mo

Re: [go-nuts] "yield" is backwards

2024-02-07 Thread Marvin Renich
* mspre...@gmail.com [240207 10:43]: > The go language is getting better and better for functional programming, > and I am here for it. I have enjoyed using APL, Scheme, Python. I was > excited to see https://go.dev/wiki/RangefuncExperiment . However, I am > puzzled by the choice to name the fu

Re: [go-nuts] "yield" is backwards

2024-02-07 Thread 'Axel Wagner' via golang-nuts
I'm not sure what you mean. The `yield` function does exactly the same as Python's `yield` statement and in fact, that's part of why the name was chosen. Compare Python: def vals(a): for v in a: yield v for x in vals([1,2,3]): print(x) With Go: func vals[T any](s []T) iter.

[go-nuts] "yield" is backwards

2024-02-07 Thread mspre...@gmail.com
The go language is getting better and better for functional programming, and I am here for it. I have enjoyed using APL, Scheme, Python. I was excited to see https://go.dev/wiki/RangefuncExperiment . However, I am puzzled by the choice to name the function parameter that _receives_ a Seq's valu