Thank you Ian, that’s very helpful context.
I understand the concern about implicit loops and the general bias against them in the language design. My thought here was that this case might be closer to the existing slice expansion at call sites (f(xs...)). In both cases we’re conceptually saying “apply this operation elementwise.” One is a function call, the other is a channel send. I agree it does expand into a loop, but it’s a loop Go programmers already write constantly in channel pipelines. I hoped that the consistency with the existing ... operator, and the frequency of the for _, v := range xs { ch <- v } pattern, might make it worth considering as one of those “common special cases.” I appreciate the feedback either way. пятница, 15 августа 2025 г. в 20:28:15 UTC+3, Ian Lance Taylor: On Fri, Aug 15, 2025 at 10:17 AM Ruslan Semagin <pixel....@gmail.com> wrote: > > I recently submitted a proposal to add slice expansion to channel send statements in Go: > > ch <- X... // X is a slice, array, *array, or string > > The proposal was closed very quickly in the tracker before any community discussion could take place. I would still like to get broader feedback from Go developers, so I’m starting this discussion here. > > The idea mirrors existing slice expansion in function calls (for example, append(dst, src...)) Note that slice expansion in function calls does not expand into a loop. When using "src..." the slice "src" is passed directly to the "...vals" parameter. Your proposal does expand into a loop. That is a property that the language reserves for some common special cases, such as conversion between string and []byte or []rune. In general the language has a bias toward not expanding into loops, as it means that the execution time of the statement is unpredictable. We would probably only do that for a case that occurs frequently and that can't be easily written as an ordinary loop. 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 visit https://groups.google.com/d/msgid/golang-nuts/d8b05046-6082-4b75-9110-ed19ad7805fen%40googlegroups.com.