]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify that iota is incremented even if not used in a const spec
authorRobert Griesemer <gri@golang.org>
Wed, 25 Nov 2015 21:18:49 +0000 (13:18 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 26 Nov 2015 17:10:22 +0000 (17:10 +0000)
Slightly modified an example.

Fixes #13371.

Change-Id: I25d260d4200086a0ef9725950132b760657610c5
Reviewed-on: https://go-review.googlesource.com/17209
Reviewed-by: Rob Pike <r@golang.org>
doc/go_spec.html

index ac5ae35745bb9efae6c1a53b8177d5efb2f96e29..7e42bc33ee45c1e1cefe3a24aeb2f9bcd522eb93 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of October 20, 2015",
+       "Subtitle": "Version of November 25, 2015",
        "Path": "/ref/spec"
 }-->
 
@@ -1789,26 +1789,27 @@ It can be used to construct a set of related constants:
 </p>
 
 <pre>
-const (  // iota is reset to 0
+const ( // iota is reset to 0
        c0 = iota  // c0 == 0
        c1 = iota  // c1 == 1
        c2 = iota  // c2 == 2
 )
 
-const (
-       a = 1 &lt;&lt; iota  // a == 1 (iota has been reset)
+const ( // iota is reset to 0
+       a = 1 &lt;&lt; iota  // a == 1
        b = 1 &lt;&lt; iota  // b == 2
-       c = 1 &lt;&lt; iota  // c == 4
+       c = 3          // c == 3  (iota is not used but still incremented)
+       d = 1 &lt;&lt; iota  // d == 8
 )
 
-const (
+const ( // iota is reset to 0
        u         = iota * 42  // u == 0     (untyped integer constant)
        v float64 = iota * 42  // v == 42.0  (float64 constant)
        w         = iota * 42  // w == 84    (untyped integer constant)
 )
 
-const x = iota  // x == 0 (iota has been reset)
-const y = iota  // y == 0 (iota has been reset)
+const x = iota  // x == 0  (iota has been reset)
+const y = iota  // y == 0  (iota has been reset)
 </pre>
 
 <p>