Commit c720875b authored by Robert Griesemer's avatar Robert Griesemer

spec: minor adjustment of prose in composite literal section

The prose discussing composite literals referred to the composite
literal type with 'LiteralType', denoting the literal type's EBNF
production explicitly. Changed 'LiteralType' to 'literal type' to
remove the literal (no pun intended) connection and instead mean
the underlying type. Seems a simpler and more readable change
than referring to the underlying type everywhere explicitly.

Fixes #12717.

Change-Id: I225df95f9ece2664b19068525ea8bda5ca05a44a
Reviewed-on: https://go-review.googlesource.com/14851Reviewed-by: 's avatarRob Pike <r@golang.org>
parent c0486b12
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of September 11, 2015",
"Subtitle": "Version of September 24, 2015",
"Path": "/ref/spec"
}-->
......@@ -2210,7 +2210,7 @@ math.Sin // denotes the Sin function in package math
<p>
Composite literals construct values for structs, arrays, slices, and maps
and create a new value each time they are evaluated.
They consist of the type of the value followed by a brace-bound list of elements.
They consist of the type of the literal followed by a brace-bound list of elements.
Each element may optionally be preceded by a corresponding key.
</p>
......@@ -2227,11 +2227,11 @@ Element = Expression | LiteralValue .
</pre>
<p>
The LiteralType must be a struct, array, slice, or map type
The LiteralType's underlying type must be a struct, array, slice, or map type
(the grammar enforces this constraint except when the type is given
as a TypeName).
The types of the elements and keys must be <a href="#Assignability">assignable</a>
to the respective field, element, and key types of the LiteralType;
to the respective field, element, and key types of the literal type;
there is no additional conversion.
The key is interpreted as a field name for struct literals,
an index for array and slice literals, and a key for map literals.
......@@ -2244,7 +2244,7 @@ constant key value.
For struct literals the following rules apply:
</p>
<ul>
<li>A key must be a field name declared in the LiteralType.
<li>A key must be a field name declared in the struct type.
</li>
<li>An element list that does not contain any keys must
list an element for each struct field in the
......@@ -2306,7 +2306,7 @@ var pointer *Point3D = &amp;Point3D{y: 1000}
</pre>
<p>
The length of an array literal is the length specified in the LiteralType.
The length of an array literal is the length specified in the literal type.
If fewer elements than the length are provided in the literal, the missing
elements are set to the zero value for the array element type.
It is an error to provide elements with index values outside the index range
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment