Re: [go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Jesse McNelis
On Fri, Dec 15, 2017 at 11:08 AM, Ivan Kurnosov wrote: > Jesse, > > what you quoted is an optimisation for the "Otherwise, the value passed is a > new slice of type []T with a new underlying array whose successive elements > ". > > Your quote says: if the final argument is assignable - it may be p

Re: [go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Ivan Kurnosov
Jesse, what you quoted is an optimisation for the "Otherwise, the value passed is a new slice of type []T with a new underlying array whose successive elements ". Your quote says: if the final argument is assignable - it may be passed as is, without any copy involving. On 15 December 2017 at 12

Re: [go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Jesse McNelis
On Fri, Dec 15, 2017 at 8:18 AM, Ivan Kurnosov wrote: > Why does this code not compile: https://play.golang.org/p/f5fMvO8Ns7 > func f(items ...interface{}) { > fmt.Println(items) > } The spec also says: "If the final argument is assignable to a slice type []T, it may be passed unchanged as the

[go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Ivan Kurnosov
Why does this code not compile: https://play.golang.org/p/f5fMvO8Ns7 package main import ( "fmt" ) func f(items ...interface{}) { fmt.Println(items) } func main() { f("a", "b", "c") tab := []interface{}{"d"} f("a", "b", "c", tab...) } The spec says: > Otherwise, the value passed is a