diff --git a/doc/go_spec.html b/doc/go_spec.html index 0ce6a3ca18..2120985b3b 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -787,32 +787,46 @@ If a variable has not yet been assigned a value, its value is the
A type determines a set of values together with operations and methods specific -to those values. A type may be denoted by a type name, if it has one, -or specified using a type literal, which composes a type from existing types. +to those values. A type may be denoted by a type name, if it has one, which must be +followed by type arguments if the type is parameterized. +A type may also be specified using a type literal, which composes a type +from existing types.
-Type = TypeName | TypeLit | "(" Type ")" .
+Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
TypeName = identifier | QualifiedIdent .
+TypeArgs = "[" TypeList [ "," ] "]" .
+TypeList = Type { "," Type } .
TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
SliceType | MapType | ChannelType .
The language predeclares certain type names. -Others are introduced with type declarations. +Others are introduced with type declarations +or type parameter lists. Composite types—array, struct, pointer, function, interface, slice, map, and channel types—may be constructed using type literals.
++Predeclared types, defined types, and type parameters are called named types. +An alias denotes a named type if the type given in the alias declaration is a named type. +
+ +
Each type T has an underlying type: If T
is one of the predeclared boolean, numeric, or string types, or a type literal,
-the corresponding underlying
-type is T itself. Otherwise, T's underlying type
-is the underlying type of the type to which T refers in its
-type declaration.
+the corresponding underlying type is T itself.
+Otherwise, T's underlying type is the underlying type of the
+type to which T refers in its type
+declaration. Accordingly, the underlying type of a type parameter is the
+underlying type of its type constraint, which
+is always an interface.
@@ -827,12 +841,15 @@ type (
B3 []B1
B4 B3
)
+
+func f[P any](x P) { … }
The underlying type of string, A1, A2, B1,
and B2 is string.
The underlying type of []B1, B3, and B4 is []B1.
+The underlying type of P is interface{}.
+A type parameter is an (unqualified) type name declared in the +type parameter list of a +function declaration or +type definition; or in the receiver specification +of a method declaration that is associated +with a parameterized type. +A type parameter acts as a place holder for an (as of yet) unknown type in the declaration; +the type parameter is replaced with a type argument upon +instantiation of the parameterized function or type. +
+ ++The properties of a type parameter are determined by its +type constraint. +
+