]> Cypherpunks repositories - gostls13.git/commitdiff
Clarify when expressions are evaluated for a range clause.
authorIan Lance Taylor <iant@golang.org>
Wed, 13 Jan 2010 20:50:45 +0000 (12:50 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 13 Jan 2010 20:50:45 +0000 (12:50 -0800)
R=gri, rsc
CC=golang-dev
https://golang.org/cl/189057

doc/go_spec.html

index f4f2f56a0d3dac8f490e2148fa034644e874674c..5243db37da58ad2232ea7ed0499d1bb0b44c04bd 100644 (file)
@@ -3783,7 +3783,12 @@ string or array element or map value.
 The types of the array or slice index (always <code>int</code>)
 and element, or of the map key and value respectively,
 must be <a href="#Assignment_compatibility">assignment compatible</a> with
-the type of the iteration variables.
+the type of the iteration variables.  The expression on the right hand
+side is evaluated once before beginning the loop.  At each iteration
+of the loop, the values produced by the range clause are assigned to
+the left hand side as in an <a href="#Assignments">assignment
+statement</a>.  Function calls on the left hand side will be evaluated
+exactly once per iteration.
 </p>
 <p>
 For strings, the "range" clause iterates over the Unicode code points