On Fri, Aug 15, 2025 at 10:17 AM Ruslan Semagin <pixel.365...@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/CAOyqgcXKZf_0zdUQs7TDi8tGf1bS5YuAPzDtjGZEwmiS%2BxRj%3DA%40mail.gmail.com.

Reply via email to