1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:04:41 -07:00

clarifying ambiguity of evaluation order

R=r
DELTA=16  (0 added, 3 deleted, 13 changed)
OCL=28133
CL=28178
This commit is contained in:
Robert Griesemer 2009-05-01 17:00:16 -07:00
parent eac5db7f4c
commit 4f18549c02

View File

@ -2905,21 +2905,18 @@ order. Otherwise, the order of evaluation is unspecified.
</p> </p>
<p> <p>
For example, while evaluating the arguments for this call For example, in the assignment
to function <code>f</code>,
</p> </p>
<pre> <pre>
f(g(), h() + x[i()], <-c) y[f()], ok = g(h(), i() + x[j()], <-c), k()
</pre> </pre>
<p> <p>
the call to <code>g()</code> happens before the call to <code>h()</code>, the function calls and communication happen in the order
which happens before the call to <code>i()</code>, all of <code>f()</code>, <code>h()</code>, <code>i()</code>, <code>j()</code>,
of which happen before receiving the value from the channel <code><-c</code>, <code>g()</code>, and <code>k()</code>.
<code>c</code>. However, the order of those events compared to the evaluation
However, the order of those events compared to the evaluation of and indexing of <code>x</code> and the evaluation
<code>f</code>, the evaluation of <code>x</code>, and the indexing of <code>y</code> is not specified.
of <code>x</code> by the return value of
<code>i()</code> is not specified.
</p> </p>
<hr/> <hr/>
@ -3164,7 +3161,7 @@ type of a specially annotated switch expression.
In an expression switch, In an expression switch,
the switch expression is evaluated and the switch expression is evaluated and
the case expressions, which need not be constants, the case expressions, which need not be constants,
are evaluated top-to-bottom; the first one that equals the are evaluated left-to-right and top-to-bottom; the first one that equals the
switch expression switch expression
triggers execution of the statements of the associated case; triggers execution of the statements of the associated case;
the other cases are skipped. the other cases are skipped.