diff --git a/doc/go_spec.html b/doc/go_spec.html index 99bedf2671..c7f93c953d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1754,6 +1754,12 @@ depending on the direction of the directional channels present. +
+By definition, a core type is never a defined type, +type parameter, or +interface type. +
+Examples of interfaces with core types:
@@ -2994,6 +3000,13 @@ non-blank identifier denoting a or a parenthesized expression. ++Operand = Literal | OperandName [ TypeArgs ] | "(" Expression ")" . +Literal = BasicLit | CompositeLit | FunctionLit . +BasicLit = int_lit | float_lit | imaginary_lit | rune_lit | string_lit . +OperandName = identifier | QualifiedIdent . ++
An operand name denoting a type-parameterized function may be followed by a list of type arguments; the @@ -3005,13 +3018,6 @@ The blank identifier may appear as an operand only on the left-hand side of an assignment.
--Operand = Literal | OperandName [ TypeArgs ] | "(" Expression ")" . -Literal = BasicLit | CompositeLit | FunctionLit . -BasicLit = int_lit | float_lit | imaginary_lit | rune_lit | string_lit . -OperandName = identifier | QualifiedIdent . --
@@ -3038,8 +3044,7 @@ math.Sin // denotes the Sin function in package math
-Composite literals construct values for structs, arrays, slices, and maps -and create a new value each time they are evaluated. +Composite literals construct new composite values each time they are evaluated. 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.
@@ -3057,11 +3062,12 @@ Element = Expression | LiteralValue .
-The LiteralType's underlying type must be a struct, array, slice, or map type
+The LiteralType's core type T
+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 assignable
-to the respective field, element, and key types of the literal type;
+to the respective field, element, and key types of type T
;
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.
@@ -3318,6 +3324,8 @@ f.p[i].x()
For a primary expression x
that is not a package name, the
@@ -3361,8 +3369,7 @@ The following rules apply to selectors:
For a value x
of type T
or *T
where T
is not a pointer or interface type,
x.f
denotes the field or method at the shallowest depth
-in T
where there
-is such an f
.
+in T
where there is such an f
.
If there is not exactly one f
with shallowest depth, the selector expression is illegal.
@@ -3722,7 +3729,8 @@ The following rules apply:
If a
is not a map:
x
must be of integer type or an untyped constantx
must be an untyped constant or its
+ core type must be an integerint
int
-For a string, array, pointer to array, or slice a
, the primary expression
+The primary expression
@@ -3852,7 +3860,9 @@ a[low : high]
-constructs a substring or slice. The indices low
and
+constructs a substring or slice. The core type of
+a
must be a string, array, pointer to array, or slice.
+The indices low
and
high
select which elements of operand a
appear
in the result. The result has indices starting at 0 and length equal to
high
- low
.
@@ -3928,7 +3938,7 @@ s2[1] = 42 // s2[1] == s1[2] == a[5] == 42; they all refer to the same under
-For an array, pointer to array, or slice a
(but not a string), the primary expression
+The primary expression
@@ -3939,6 +3949,8 @@ a[low : high : max] constructs a slice of the same type, and with the same length and elements as the simple slice expressiona[low : high]
. Additionally, it controls the resulting slice's capacity by setting it tomax - low
. Only the first index may be omitted; it defaults to 0. +The core type ofa
must be an array, pointer to array, +or slice (but not a string). After slicing the arraya
@@ -4044,8 +4056,8 @@ No run-time panic occurs in this case.Calls
-Given an expression
f
of function type -F
, +Given an expressionf
with a core type +F
of function type,@@ -5148,7 +5160,8 @@ var x *int = nil+Receive operator
-For an operand
ch
of channel type, +For an operandch
whose core type is a +channel, the value of the receive operation<-ch
is the value received from the channelch
. The channel direction must permit receive operations, and the type of the receive operation is the element type of the channel. @@ -5861,7 +5874,8 @@ len("foo") // illegal if len is the built-in functionA send statement sends a value on a channel. -The channel expression must be of channel type, +The channel expression's core type +must be a channel, the channel direction must permit send operations, and the type of the value to be sent must be assignable to the channel's element type. @@ -6407,7 +6421,8 @@ RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .
The expression on the right in the "range" clause is called the range expression, -which may be an array, pointer to an array, slice, string, map, or channel permitting +its core type must be +an array, pointer to an array, slice, string, map, or channel permitting receive operations. As with an assignment, if present the operands on the left must be addressable or map index expressions; they @@ -6992,9 +7007,10 @@ they cannot be used as function values.
Close
-For a channel
c
, the built-in functionclose(c)
+For an argumentch
with a core type +that is a channel, the built-in functionclose
records that no more values will be sent on the channel. -It is an error ifc
is a receive-only channel. +It is an error ifch
is a receive-only channel. Sending to or closing a closed channel causes a run-time panic. Closing the nil channel also causes a run-time panic. After callingclose
, and after any previously @@ -7110,24 +7126,25 @@ of the location.The built-in function
make
takes a typeT
, -which must be a slice, map or channel type, optionally followed by a type-specific list of expressions. +The core type ofT
must +be a slice, map or channel. It returns a value of typeT
(not*T
). The memory is initialized as described in the section on initial values.-Call Type T Result +Call Core type Result -make(T, n) slice slice of type T with length n and capacity n -make(T, n, m) slice slice of type T with length n and capacity m +make(T, n) slice slice of type T with length n and capacity n +make(T, n, m) slice slice of type T with length n and capacity m -make(T) map map of type T -make(T, n) map map of type T with initial space for approximately n elements +make(T) map map of type T +make(T, n) map map of type T with initial space for approximately n elements -make(T) channel unbuffered channel of type T -make(T, n) channel buffered channel of type T, buffer size n +make(T) channel unbuffered channel of type T +make(T, n) channel buffered channel of type T, buffer size n@@ -7169,21 +7186,20 @@ by the arguments overlaps.The variadic function
append
-appends zero or more valuesx
-tos
of typeS
, which must be a slice type, and -returns the resulting slice, also of typeS
. -The valuesx
are passed to a parameter of type...T
-whereT
is the element type of -S
and the respective -parameter passing rules apply. -As a special case,append
also accepts a first argument -assignable to type[]byte
with a second argument of -string type followed by...
. This form appends the -bytes of the string. +appends zero or more valuesx
to a slices
+and returns the resulting slice. +The core type ofs
must be a slice +of the form[]E
. +The valuesx
are passed to a parameter of type...E
+and the respective parameter +passing rules apply. +As a special case, if the core type ofs
is[]byte
, +append
also accepts a second argument with core typestring
+followed by...
. This form appends the bytes of the string.-append(s S, x ...T) S // T is the element type of S +append(s S, x ...E) S // E is the element type of the core type of S@@ -7211,12 +7227,12 @@ b = append(b, "bar"...) // append string contents b == []byte{'b The function
@@ -7252,6 +7268,12 @@ to the key type ofcopy
copies slice elements from a sourcesrc
to a destinationdst
and returns the number of elements copied. -Both arguments must have identical element typeT
and must be -assignable to a slice of type[]T
. +The core types of both arguments must be slices +with identical element type. The number of elements copied is the minimum oflen(src)
andlen(dst)
. -As a special case,copy
also accepts a destination argument assignable -to type[]byte
with a source argument of a string type. +As a special case, if the destination's core type is[]byte
, +copy
also accepts a source argument with core typestring
. This form copies the bytes from the string into the byte slice.m
. delete(m, k) // remove element m[k] from map m+If the type of
+m
is a type parameter, +it must have specific types, all specific types +must be maps, and they must all have identical key types. +If the map
m
isnil
or the elementm[k]
does not exist,delete
is a no-op. @@ -7260,6 +7282,8 @@ does not exist,delete
is a no-op.Manipulating complex numbers
+ +Three functions assemble and disassemble complex numbers. The built-in function
complex
constructs a complex