1
0
mirror of https://github.com/golang/go synced 2024-09-23 23:10:13 -06:00

spec: consistently use "element" rather than "value" for map entry values

The spec refers to a map's key and element types; thus the respective
values are "keys" and "elements". Also, a map value is the value of
the entire map.

Similar fix for channels, where appropriate.

Fixes #23254.

Change-Id: I6f03ea6d86586c7b0b3e84f0c2e9446b8109fa53
Reviewed-on: https://go-review.googlesource.com/85999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Robert Griesemer 2018-01-03 10:33:11 -08:00
parent 3f150934e2
commit 4de1d1d5cd

View File

@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of December 21, 2017",
"Subtitle": "Version of January 3, 2018",
"Path": "/ref/spec"
}-->
@ -1453,9 +1453,9 @@ components have identical types. In detail:
<a href="#Exported_identifiers">Non-exported</a> method names from different
packages are always different. The order of the methods is irrelevant.</li>
<li>Two map types are identical if they have identical key and value types.</li>
<li>Two map types are identical if they have identical key and element types.</li>
<li>Two channel types are identical if they have identical value types and
<li>Two channel types are identical if they have identical element types and
the same direction.</li>
</ul>
@ -3033,11 +3033,11 @@ For <code>a</code> of <a href="#Map_types">map type</a> <code>M</code>:
<a href="#Assignability">assignable</a>
to the key type of <code>M</code></li>
<li>if the map contains an entry with key <code>x</code>,
<code>a[x]</code> is the map value with key <code>x</code>
and the type of <code>a[x]</code> is the value type of <code>M</code></li>
<code>a[x]</code> is the map element with key <code>x</code>
and the type of <code>a[x]</code> is the element type of <code>M</code></li>
<li>if the map is <code>nil</code> or does not contain such an entry,
<code>a[x]</code> is the <a href="#The_zero_value">zero value</a>
for the value type of <code>M</code></li>
for the element type of <code>M</code></li>
</ul>
<p>
@ -5122,7 +5122,7 @@ for i, s := range a {
}
var key string
var val interface {} // value type of m is assignable to val
var val interface {} // element type of m is assignable to val
m := map[string]int{"mon":0, "tue":1, "wed":2, "thu":3, "fri":4, "sat":5, "sun":6}
for key, val = range m {
h(key, val)