On Tue, Mar 20, 2018 at 8:45 AM, T L <tapir....@gmail.com> wrote:
> The Go specification only says
>
> In a function call, the function value and arguments are evaluated in the
> usual order.
>
> 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?

I believe that is correct.  And, further, if a and/or m are global
variables, then exactly when the values of those global variables is
fetched is unspecified; this matters if any of the function calls
modify those global variables.

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

Reply via email to