On Tuesday, March 20, 2018 at 11:45:02 AM UTC-4, T L wrote:
>
> The Go specification only says
>
> In a function call, the function value and arguments are evaluated in the
> usual order <https://tip.golang.org/ref/spec#Order_of_evaluation>.
>
> The usual order is explained here:
> https://tip.golang.org/ref/spec#Order_of_evaluation
> But I am not clear on what the usual order means for argument evaluation
> order.
> Does it mean the function calls in the argument list are evaluated by
> their lexical left-to-right order?
> Beside this guarantee, no other guarantee exist.
>
> For example, for this function call
>
> f(g(), a[1], h(), m["abc"], q())
>
> g() is evaluated before h(), and h() is evaluated before q(),
> but the evaluation order of a[1] and m["abc"] is not specified?
>
For the following example, the output may be any of "1 7 2", "1 8 2" and "1
9 2"?
package main
import "fmt"
func main() {
x, y := 0, 0
f := func() int {
x++
y++
return x
}
fmt.Println(f(), y, f())
}
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.