]> Cypherpunks repositories - gostls13.git/commitdiff
Allow indexing of slice types, but not pointer to slice type.
authorRuss Cox <rsc@golang.org>
Thu, 25 Jun 2009 21:43:55 +0000 (14:43 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 25 Jun 2009 21:43:55 +0000 (14:43 -0700)
Allow indexing of string type, but not pointer to string type.
Do not allow indexing of pointer to map type.

R=r
DELTA=18  (14 added, 0 deleted, 4 changed)
OCL=30586
CL=30754

doc/go_spec.html

index 37faf1c905c1248fce81696b219f7e5e17be355f..ef39535d6f4746e5e23e0f5eb0c76eb521dfde82 100644 (file)
@@ -2155,17 +2155,31 @@ The value <code>x</code> is called the
 <i>array index</i> or <i>map key</i>, respectively. The following
 rules apply:
 </p>
+
 <p>
 For <code>a</code> of type <code>A</code> or <code>*A</code>
-where <code>A</code> is an array type (§Array types):
+where <code>A</code> is an array type (§Array types),
+or for <code>a</code> of type <code>S</code> where <code>S</code> is a slice type (§Slice types):
 </p>
 <ul>
        <li><code>x</code> must be an integer value and <code>0 &lt;= x &lt; len(a)</code>
        <li><code>a[x]</code> is the array element at index <code>x</code> and the type of
          <code>a[x]</code> is the element type of <code>A</code>
 </ul>
+
+<p>
+For <code>a</code> of type <code>T</code>
+where <code>T</code> is a string type (§Strings):
+</p>
+<ul>
+       <li><code>x</code> must be an integer value and <code>0 &lt;= x &lt; len(a)</code>
+       <li><code>a[x]</code> is the byte at index <code>x</code> and the type of
+         <code>a[x]</code> is <code>byte</code>
+       <li><code>a[x]</code> may not be assigned to
+</ul>
+
 <p>
-For <code>a</code> of type <code>M</code> or <code>*M</code>
+For <code>a</code> of type <code>M</code>
 where <code>M</code> is a map type (§Map types):
 </p>
 <ul>
@@ -2248,7 +2262,7 @@ For arrays or strings, the indexes
 for slices, the upper bound is the capacity rather than the length.
 <p>
 If the sliced operand is a string, the result of the slice operation is another, new
-string (§String types). If the sliced operand is an array or slice, the result
+string (§Strings). If the sliced operand is an array or slice, the result
 of the slice operation is a slice (§Slice types).
 </p>