The spec defines `append` as a variadic function, with a type of the form 

append(s S, x ...T) S  // T is the element type of S

Variadic functions, in general, accept zero or more parameters. (Consider 
fmt.Println().)

In order to reject empty appends, append would either have to have its own 
special type structure (not just a variadic function), or it would have to 
be of the form

append(s S, x T, xs ...T) S

The former would increase the complexity of the language spec for little 
benefit. The latter would break call sites that look like

foo = append(foo, bar...)

 
As Axel and Dave suggest, this would probably be reasonable for a linter 
(or cmd/vet) to warn about.


On Sunday, December 3, 2017 at 7:09:39 PM UTC-5, nz wrote:
>
> My point is that it should give an error or refuse to compile.
>
> On Sunday, 3 December 2017 15:10:42 UTC-8, Dave Cheney wrote:
>>
>> What is the error? This construct seems harmless.
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to