<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of December 10, 2012",
+ "Subtitle": "Version of December 12, 2012",
"Path": "/ref/spec"
}-->
</pre>
<p>
-The length is part of the array's type and must be a
-<a href="#Constant_expressions">constant expression</a> that evaluates to a non-negative
-integer value. The length of array <code>a</code> can be discovered
+The length is part of the array's type; it must evaluate to a non-
+negative <a href="#Constants">constant</a> representable by a value
+of type <code>int</code>.
+The length of array <code>a</code> can be discovered
using the built-in function <a href="#Length_and_capacity"><code>len</code></a>.
The elements can be addressed by integer <a href="#Index_expressions">indices</a>
-indices 0 through <code>len(a)-1</code>.
+0 through <code>len(a)-1</code>.
Array types are always one-dimensional but may be composed to form
multi-dimensional types.
</p>
rules apply:
</p>
+<p>
+If <code>a</code> is not a map:
+</p>
+<ul>
+ <li>the index <code>x</code> must be an integer value; it is <i>in range</i> if <code>0 <= x < len(a)</code>,
+ otherwise it is <i>out of range</i></li>
+ <li>a <a href="#Constants">constant</a> index must be non-negative
+ and representable by a value of type <code>int</code>
+</ul>
+
<p>
For <code>a</code> of type <code>A</code> or <code>*A</code>
where <code>A</code> is an <a href="#Array_types">array type</a>:
</p>
<ul>
- <li><code>x</code> must be an integer value; it is <i>in range</i> if <code>0 <= x < len(a)</code>,
- otherwise it is <i>out of range</i></li>
<li>a <a href="#Constants">constant</a> index must be in range</li>
<li>if <code>a</code> is <code>nil</code> or if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li>
For <code>a</code> of type <code>S</code> where <code>S</code> is a <a href="#Slice_types">slice type</a>:
</p>
<ul>
- <li><code>x</code> must be an integer value; it is <i>in range</i> if <code>0 <= x < len(a)</code>,
- otherwise it is <i>out of range</i></li>
- <li>a <a href="#Constants">constant</a> index must not be negative</li>
<li>if the slice is <code>nil</code> or if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li>
<li><code>a[x]</code> is the slice element at index <code>x</code> and the type of
where <code>T</code> is a <a href="#String_types">string type</a>:
</p>
<ul>
- <li><code>x</code> must be an integer value; it is <i>in range</i> if <code>0 <= x < len(a)</code>,
- otherwise it is <i>out of range</i></li>
- <li>a <a href="#Constants">constant</a> index must not be negative, and it must be in range
+ <li>a <a href="#Constants">constant</a> index must be in range
if the string <code>a</code> is also constant</li>
<li>if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li>
<i>in range</i> if <code>0 <= <code>low</code> <= <code>high</code> <= len(a)</code>,
otherwise they are <i>out of range</i>.
For slices, the upper index bound is the slice capacity <code>cap(a)</code> rather than the length.
-A <a href="#Constant_expressions">constant</a> index must not be negative, and if both indices
+A <a href="#Constants">constant</a> index must be non-negative and representable by a value of type
+<code>int</code>.
+If both indices
are constant, they must satisfy <code>low <= high</code>. If <code>a</code> is <code>nil</code>
or if the indices are out of range at run time, a <a href="#Run_time_panics">run-time panic</a> occurs.
</p>
<p>
The size arguments <code>n</code> and <code>m</code> must be integer values.
-A <a href="#Constants">constant</a> size argument must not be negative, and
-if both <code>n</code> and <code>m</code> are provided and are constant, then
+A <a href="#Constants">constant</a> size argument must be non-negative and
+representable by a value of type <code>int</code>.
+If both <code>n</code> and <code>m</code> are provided and are constant, then
<code>n</code> must be no larger than <code>m</code>.
If <code>n</code> is negative or larger than <code>m</code> at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs.
<pre>
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
+s := make([]int, 1<<63) // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0) // illegal: len(s) > cap(s)
c := make(chan int, 10) // channel with a buffer size of 10
m := make(map[string]int, 100) // map with initial space for 100 elements