diff options
author | Robert Griesemer <gri@golang.org> | 2022-03-10 17:40:01 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2022-03-11 06:00:18 +0000 |
commit | fe75fe3c7ae99713ed4e452ea8a4fcb589517dd9 (patch) | |
tree | 40ed925086d74a4eb884918035e9c7e35510d6e9 /doc | |
parent | 59d80227effa3027a37b1aa85eef88d1df7b1e81 (diff) | |
download | go-fe75fe3c7ae99713ed4e452ea8a4fcb589517dd9.tar.gz go-fe75fe3c7ae99713ed4e452ea8a4fcb589517dd9.zip |
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>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go_spec.html | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 9b37e0ded08..ad12fcfaa99 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -7116,8 +7116,9 @@ make(T, n) channel buffered channel of type T, buffer size n <p> -Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a> -or an untyped <a href="#Constants">constant</a>. +Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>, +have a <a href="#Interface_types">type set</a> containing only integer types, +or be an untyped <a href="#Constants">constant</a>. A constant size argument must be non-negative and <a href="#Representability">representable</a> by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>. If both <code>n</code> and <code>m</code> are provided and are constant, then @@ -7154,9 +7155,9 @@ by the arguments overlaps. <p> The <a href="#Function_types">variadic</a> function <code>append</code> appends zero or more values <code>x</code> to a slice <code>s</code> -and returns the resulting slice. +and returns the resulting slice of the same type as <code>s</code>. The <a href="#Core_types">core type</a> of <code>s</code> must be a slice -of the form <code>[]E</code>. +of type <code>[]E</code>. The values <code>x</code> are passed to a parameter of type <code>...E</code> and the respective <a href="#Passing_arguments_to_..._parameters">parameter passing rules</a> apply. @@ -7166,7 +7167,7 @@ followed by <code>...</code>. This form appends the bytes of the string. </p> <pre class="grammar"> -append(s S, x ...E) S // E is the element type of the core type of S +append(s S, x ...E) S // core type of S is []E </pre> <p> @@ -7922,11 +7923,17 @@ func Add(ptr Pointer, len IntegerType) Pointer func Slice(ptr *ArbitraryType, len IntegerType) []ArbitraryType </pre> +<!-- +These conversions also apply to type parameters with suitable core types. +Determine if we can simply use core type insted of underlying type here, +of if the general conversion rules take care of this. +--> + <p> A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code> value may not be <a href="#Address_operators">dereferenced</a>. -Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted to -a type of underlying type <code>Pointer</code> and vice versa. +Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be +<a href="#Conversions">converted</a> to a type of underlying type <code>Pointer</code> and vice versa. The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined. </p> @@ -7973,7 +7980,8 @@ uintptr(unsafe.Pointer(&x)) % unsafe.Alignof(x) == 0 <p> A (variable of) type <code>T</code> has <i>variable size</i> if <code>T</code> -is a type parameter, or if it is an array or struct type containing elements +is a <a href="#Type_parameter_declarations">type parameter</a>, or if it is an +array or struct type containing elements or fields of variable size. Otherwise the size is <i>constant</i>. Calls to <code>Alignof</code>, <code>Offsetof</code>, and <code>Sizeof</code> are compile-time <a href="#Constant_expressions">constant expressions</a> of |