>   "when evaluating the operands of an expression, assignment, or return 
> statement, all function calls, method calls, and communication operations are 
> evaluated in lexical left-to-right order."

My understanding goes as follows: the operands of the return statement
are i and modify(&i). The comma after "return statement" in the above
sentence is then important: because the only "function calls, method
calls, and communication operations" in that list of operands are (is)
modify(&i).

Hence when i (as in the first operand) is evaluated is not specified.
And therefore it's dangerous to rely on it being one value or another
(which it could be given the example you provide).

There was even some discussion at the London Gophers November 2019
meetup (where the conundrum was very related
https://docs.google.com/presentation/d/e/2PACX-1vQ07uP_ldnSYzpaNb5AlZZ-_tL2mZuoNfQgxvsTKSM4aglYR-nuvyrZ8nK__r3YQTo1vqH-Hmax3aXs/pub?slide=id.g6239d05d0e_0_1)
about whether it would be possible to statically flag potential errors
like this.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACoUkn7KA0Z-TDypdvM%3Du%3DyVPHuHFmtD%3DiTV2c98Vm%3Dqn4NcPw%40mail.gmail.com.

Reply via email to