]> Cypherpunks repositories - gostls13.git/commitdiff
spec: add subtitles to section on "for" statements
authorRobert Griesemer <gri@golang.org>
Fri, 18 Nov 2016 18:49:29 +0000 (10:49 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 18 Nov 2016 20:26:11 +0000 (20:26 +0000)
This matches what we already do for switch statements and makes
this large section more visibly organized. No other changes besides
introducing the titles.

Fixes #4486.

Change-Id: I73f274e4fdd27c6cfeaed79090b4553e57a9c479
Reviewed-on: https://go-review.googlesource.com/33410
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
doc/go_spec.html

index 1a60a9eac7bb812b5e8394baa840c811ba220127..5872eefb03f3d9ad7c8241a4d228711f6f24ca1c 100644 (file)
@@ -4799,8 +4799,8 @@ The "fallthrough" statement is not permitted in a type switch.
 <h3 id="For_statements">For statements</h3>
 
 <p>
-A "for" statement specifies repeated execution of a block. The iteration is
-controlled by a condition, a "for" clause, or a "range" clause.
+A "for" statement specifies repeated execution of a block. There are three forms:
+The iteration may be controlled by a single condition, a "for" clause, or a "range" clause.
 </p>
 
 <pre class="ebnf">
@@ -4808,6 +4808,8 @@ ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
 Condition = Expression .
 </pre>
 
+<h4 id="For_condition">For statements with single condition</h4>
+
 <p>
 In its simplest form, a "for" statement specifies the repeated execution of
 a block as long as a boolean condition evaluates to true.
@@ -4822,6 +4824,8 @@ for a &lt; b {
 }
 </pre>
 
+<h4 id="For_clause">For statements with <code>for</code> clause</h4>
+
 <p>
 A "for" statement with a ForClause is also controlled by its condition, but
 additionally it may specify an <i>init</i>
@@ -4860,6 +4864,8 @@ for cond { S() }    is the same as    for ; cond ; { S() }
 for      { S() }    is the same as    for true     { S() }
 </pre>
 
+<h4 id="For_range">For statements with <code>range</code> clause</h4>
+
 <p>
 A "for" statement with a "range" clause
 iterates through all entries of an array, slice, string or map,