From: Robert Griesemer Date: Thu, 25 Sep 2014 19:52:05 +0000 (-0700) Subject: spec: clarify scope and re-use of iteration variables X-Git-Tag: go1.4beta1~288 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2fa3e43fae867f5b8757780eb2bbf7444b56f5d5;p=gostls13.git spec: clarify scope and re-use of iteration variables Fixes #7834. LGTM=iant, rsc, r R=r, rsc, iant, ken CC=golang-codereviews https://golang.org/cl/148940044 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index e0ed7e7b74..583517269c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -4682,6 +4682,7 @@ additionally it may specify an init and a post statement, such as an assignment, an increment or decrement statement. The init statement may be a short variable declaration, but the post statement must not. +Variables declared by the init statement are re-used in each iteration.

@@ -4808,7 +4809,7 @@ The iteration variables may be declared by the "range" clause using a form of
 short variable declaration
 (:=).
 In this case their types are set to the types of the respective iteration values
-and their scope ends at the end of the "for"
+and their scope is the block of the "for"
 statement; they are re-used in each iteration.
 If the iteration variables are declared outside the "for" statement,
 after execution their values will be those of the last iteration.