Thanks for clarifying, Ian. You are right, variadic expansion doesn’t 
literally apply element by element — the slice is passed as-is.

What I meant to highlight is the *mental model* programmers already use: 
when reading `f(xs...)` it is commonly understood as “take all the elements 
and pass them along.” My thought was that `ch <- xs...` extends that same 
intuition into channel sends, even though the mechanics differ internally.

So the comparison was more about readability and consistency from the 
user’s perspective, not about the underlying implementation. In that sense, 
`ch <- xs...` is intended as a lightweight, expressive shorthand for a very 
common loop, similar to how variadics provide an expressive shorthand for 
building argument lists.


воскресенье, 17 августа 2025 г. в 02:25:47 UTC+3, Ian Lance Taylor: 

> On Sat, Aug 16, 2025 at 1:21 AM Ruslan Semagin <pixel....@gmail.com> 
> wrote:
> >
> > 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.
>
> But the function call is not applied elementwise. As I tried to
> explain, the slice is passed directly, not element by element. See
> https://go.dev/play/p/R4B1wHZMTuL.
>
> 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/9e3f90a5-5c3f-444f-a2b8-0b93840253d7n%40googlegroups.com.

Reply via email to