X Tutup
Skip to content

Commit fe75fe3

Browse files
committed
spec: various minor clarifications
- Allow for a type parameter as length/capacity to make. - Be slightly more precise in prose for append. - Add a couple of links. Change-Id: Ib97e528bab1ab55d271beeeb53d9bb7a07047b9b Reviewed-on: https://go-review.googlesource.com/c/go/+/391754 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 parent 59d8022 commit fe75fe3

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

doc/go_spec.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7116,8 +7116,9 @@ <h3 id="Making_slices_maps_and_channels">Making slices, maps and channels</h3>
71167116

71177117

71187118
<p>
7119-
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>
7120-
or an untyped <a href="#Constants">constant</a>.
7119+
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
7120+
have a <a href="#Interface_types">type set</a> containing only integer types,
7121+
or be an untyped <a href="#Constants">constant</a>.
71217122
A constant size argument must be non-negative and <a href="#Representability">representable</a>
71227123
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
71237124
If both <code>n</code> and <code>m</code> are provided and are constant, then
@@ -7154,9 +7155,9 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
71547155
<p>
71557156
The <a href="#Function_types">variadic</a> function <code>append</code>
71567157
appends zero or more values <code>x</code> to a slice <code>s</code>
7157-
and returns the resulting slice.
7158+
and returns the resulting slice of the same type as <code>s</code>.
71587159
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
7159-
of the form <code>[]E</code>.
7160+
of type <code>[]E</code>.
71607161
The values <code>x</code> are passed to a parameter of type <code>...E</code>
71617162
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
71627163
passing rules</a> apply.
@@ -7166,7 +7167,7 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
71667167
</p>
71677168

71687169
<pre class="grammar">
7169-
append(s S, x ...E) S // E is the element type of the core type of S
7170+
append(s S, x ...E) S // core type of S is []E
71707171
</pre>
71717172

71727173
<p>
@@ -7922,11 +7923,17 @@ <h3 id="Package_unsafe">Package <code>unsafe</code></h3>
79227923
func Slice(ptr *ArbitraryType, len IntegerType) []ArbitraryType
79237924
</pre>
79247925

7926+
<!--
7927+
These conversions also apply to type parameters with suitable core types.
7928+
Determine if we can simply use core type insted of underlying type here,
7929+
of if the general conversion rules take care of this.
7930+
-->
7931+
79257932
<p>
79267933
A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code>
79277934
value may not be <a href="#Address_operators">dereferenced</a>.
7928-
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted to
7929-
a type of underlying type <code>Pointer</code> and vice versa.
7935+
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be
7936+
<a href="#Conversions">converted</a> to a type of underlying type <code>Pointer</code> and vice versa.
79307937
The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined.
79317938
</p>
79327939

@@ -7973,7 +7980,8 @@ <h3 id="Package_unsafe">Package <code>unsafe</code></h3>
79737980

79747981
<p>
79757982
A (variable of) type <code>T</code> has <i>variable size</i> if <code>T</code>
7976-
is a type parameter, or if it is an array or struct type containing elements
7983+
is a <a href="#Type_parameter_declarations">type parameter</a>, or if it is an
7984+
array or struct type containing elements
79777985
or fields of variable size. Otherwise the size is <i>constant</i>.
79787986
Calls to <code>Alignof</code>, <code>Offsetof</code>, and <code>Sizeof</code>
79797987
are compile-time <a href="#Constant_expressions">constant expressions</a> of

0 commit comments

Comments
 (0)
X Tutup