Re: [go-nuts] Calling function with variadic arguments

2018-11-13 Thread Ian Lance Taylor
On Tue, Nov 13, 2018 at 1:29 AM, Sergey Kamardin wrote: > > Sorry for my previous misunderstanding. Now I realized that there no > ability in general to get the knowledge of how that slice of variadic > arguments will be used inside hidden interface method implementation. > > Also, is it correct

Re: [go-nuts] Calling function with variadic arguments

2018-11-13 Thread Sergey Kamardin
Hi again, Sorry for my previous misunderstanding. Now I realized that there no ability in general to get the knowledge of how that slice of variadic arguments will be used inside hidden interface method implementation. Also, is it correct to think about variadic arguments just like about regular

Re: [go-nuts] Calling function with variadic arguments

2018-11-12 Thread Sergey Kamardin
Thank you for the reply. > The optimization you are talking about is escape analysis. I was trying to point not the escape analysis itself, but the ability of the compiler to construct stack-based slice for the variadic arguments instead of heap-based slices (like it does with the interfaces).

Re: [go-nuts] Calling function with variadic arguments

2018-11-12 Thread Ian Lance Taylor
On Mon, Nov 12, 2018 at 4:24 AM, Sergey Kamardin wrote: > > Also, I may assume that this because the compiler does not knows exactly > which function it will call in a runtime. Most likely, yes. > Am I understand it right and are there any plans for preparing such > optimizations? The

[go-nuts] Calling function with variadic arguments

2018-11-12 Thread Sergey Kamardin
Hello gophers, Does Go compiler has some optimizations for function and *method* calls with `variadic` arguments? For example, this simple benchmark: ``` package main import "testing" func Do(xs ...int) (s int) { for i, x := range xs { s += i + x }