From 15a4e0d9703033e0b2be4dc6830f03570df7943e Mon Sep 17 00:00:00 2001
From: Robert Griesemer
-The built-in function clear takes an argument of map,
-slice, or type parameter type,
-and deletes or zeroes out all elements.
-
-Call Argument type Result
-
-clear(m) map[K]T deletes all entries, resulting in an
- empty map (len(m) == 0)
-
-clear(s) []T sets all elements up to the length of
- s to the zero value of T
-
-clear(t) type parameter see below
-
-
-
-If the argument type is a type parameter,
-all types in its type set must be maps or slices, and clear
-performs the operation corresponding to the actual type argument.
-
-If the map or slice is nil, clear is a no-op.
-
-For an argument ch with a core type
-that is a channel, the built-in function close
-records that no more values will be sent on the channel.
-It is an error if ch 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 calling close, and after any previously
-sent values have been received, receive operations will return
-the zero value for the channel's type without blocking.
-The multi-valued receive operation
-returns a received value along with an indication of whether the channel is closed.
-
-The built-in functions len and cap take arguments
-of various types and return a result of type int.
-The implementation guarantees that the result always fits into an int.
-
-Call Argument type Result - -len(s) string type string length in bytes - [n]T, *[n]T array length (== n) - []T slice length - map[K]T map length (number of defined keys) - chan T number of elements queued in channel buffer - type parameter see below - -cap(s) [n]T, *[n]T array length (== n) - []T slice capacity - chan T channel buffer capacity - type parameter see below -- -
-If the argument type is a type parameter P,
-the call len(e) (or cap(e) respectively) must be valid for
-each type in P's type set.
-The result is the length (or capacity, respectively) of the argument whose type
-corresponds to the type argument with which P was
-instantiated.
-
-The capacity of a slice is the number of elements for which there is -space allocated in the underlying array. -At any time the following relationship holds: -
- --0 <= len(s) <= cap(s) -- -
-The length of a nil slice, map or channel is 0.
-The capacity of a nil slice or channel is 0.
-
-The expression len(s) is constant if
-s is a string constant. The expressions len(s) and
-cap(s) are constants if the type of s is an array
-or pointer to an array and the expression s does not contain
-channel receives or (non-constant)
-function calls; in this case s is not evaluated.
-Otherwise, invocations of len and cap are not
-constant and s is evaluated.
-
-const (
- c1 = imag(2i) // imag(2i) = 2.0 is a constant
- c2 = len([10]float64{2}) // [10]float64{2} contains no function calls
- c3 = len([10]float64{c1}) // [10]float64{c1} contains no function calls
- c4 = len([10]float64{imag(2i)}) // imag(2i) is a constant and no function call is issued
- c5 = len([10]float64{imag(z)}) // invalid: imag(z) is a (non-constant) function call
-)
-var z complex128
-
-
-
-The built-in function new takes a type T,
-allocates storage for a variable of that type
-at run time, and returns a value of type *T
-pointing to it.
-The variable is initialized as described in the section on
-initial values.
-
-new(T) -- -
-For instance -
- -
-type S struct { a int; b float64 }
-new(S)
-
-
-
-allocates storage for a variable of type S,
-initializes it (a=0, b=0.0),
-and returns a value of type *S containing the address
-of the location.
-
-The built-in function make takes a type T,
-optionally followed by a type-specific list of expressions.
-The core type of T must
-be a slice, map or channel.
-It returns a value of type T (not *T).
-The memory is initialized as described in the section on
-initial values.
-
-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) 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 -- - -
-Each of the size arguments n and m must be of integer type,
-have a type set containing only integer types,
-or be an untyped constant.
-A constant size argument must be non-negative and representable
-by a value of type int; if it is an untyped constant it is given type int.
-If both n and m are provided and are constant, then
-n must be no larger than m.
-For slices and channels, if n is negative or larger than m at run time,
-a run-time panic occurs.
-
-s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100 -s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000 -s := make([]int, 1<<63) // illegal: len(s) is not representable by a value of type int -s := make([]int, 10, 0) // illegal: len(s) > cap(s) -c := make(chan int, 10) // channel with a buffer size of 10 -m := make(map[string]int, 100) // map with initial space for approximately 100 elements -- -
-Calling make with a map type and size hint n will
-create a map with initial space to hold n map elements.
-The precise behavior is implementation-dependent.
-
-The built-in function delete removes the element with key
-k from a map m. The
-value k must be assignable
-to the key type of m.
+The built-in function clear takes an argument of map,
+slice, or type parameter type,
+and deletes or zeroes out all elements.
-delete(m, k) // remove element m[k] from map m
+Call Argument type Result
+
+clear(m) map[K]T deletes all entries, resulting in an
+ empty map (len(m) == 0)
+
+clear(s) []T sets all elements up to the length of
+ s to the zero value of T
+
+clear(t) type parameter see below
-If the type of m is a type parameter,
-all types in that type set must be maps, and they must all have identical key types.
+If the argument type is a type parameter,
+all types in its type set must be maps or slices, and clear
+performs the operation corresponding to the actual type argument.
-If the map m is nil or the element m[k]
-does not exist, delete is a no-op.
+If the map or slice is nil, clear is a no-op.
+
+For an argument ch with a core type
+that is a channel, the built-in function close
+records that no more values will be sent on the channel.
+It is an error if ch 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 calling close, and after any previously
+sent values have been received, receive operations will return
+the zero value for the channel's type without blocking.
+The multi-valued receive operation
+returns a received value along with an indication of whether the channel is closed.
+The built-in function delete removes the element with key
+k from a map m. The
+value k must be assignable
+to the key type of m.
+
+delete(m, k) // remove element m[k] from map m ++ +
+If the type of m is a type parameter,
+all types in that type set must be maps, and they must all have identical key types.
+
+If the map m is nil or the element m[k]
+does not exist, delete is a no-op.
+
+The built-in functions len and cap take arguments
+of various types and return a result of type int.
+The implementation guarantees that the result always fits into an int.
+
+Call Argument type Result + +len(s) string type string length in bytes + [n]T, *[n]T array length (== n) + []T slice length + map[K]T map length (number of defined keys) + chan T number of elements queued in channel buffer + type parameter see below + +cap(s) [n]T, *[n]T array length (== n) + []T slice capacity + chan T channel buffer capacity + type parameter see below ++ +
+If the argument type is a type parameter P,
+the call len(e) (or cap(e) respectively) must be valid for
+each type in P's type set.
+The result is the length (or capacity, respectively) of the argument whose type
+corresponds to the type argument with which P was
+instantiated.
+
+The capacity of a slice is the number of elements for which there is +space allocated in the underlying array. +At any time the following relationship holds: +
+ ++0 <= len(s) <= cap(s) ++ +
+The length of a nil slice, map or channel is 0.
+The capacity of a nil slice or channel is 0.
+
+The expression len(s) is constant if
+s is a string constant. The expressions len(s) and
+cap(s) are constants if the type of s is an array
+or pointer to an array and the expression s does not contain
+channel receives or (non-constant)
+function calls; in this case s is not evaluated.
+Otherwise, invocations of len and cap are not
+constant and s is evaluated.
+
+const (
+ c1 = imag(2i) // imag(2i) = 2.0 is a constant
+ c2 = len([10]float64{2}) // [10]float64{2} contains no function calls
+ c3 = len([10]float64{c1}) // [10]float64{c1} contains no function calls
+ c4 = len([10]float64{imag(2i)}) // imag(2i) is a constant and no function call is issued
+ c5 = len([10]float64{imag(z)}) // invalid: imag(z) is a (non-constant) function call
+)
+var z complex128
+
+
+
+
+The built-in function make takes a type T,
+optionally followed by a type-specific list of expressions.
+The core type of T must
+be a slice, map or channel.
+It returns a value of type T (not *T).
+The memory is initialized as described in the section on
+initial values.
+
+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) 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 ++ +
+Each of the size arguments n and m must be of integer type,
+have a type set containing only integer types,
+or be an untyped constant.
+A constant size argument must be non-negative and representable
+by a value of type int; if it is an untyped constant it is given type int.
+If both n and m are provided and are constant, then
+n must be no larger than m.
+For slices and channels, if n is negative or larger than m at run time,
+a run-time panic occurs.
+
+s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100 +s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000 +s := make([]int, 1<<63) // illegal: len(s) is not representable by a value of type int +s := make([]int, 10, 0) // illegal: len(s) > cap(s) +c := make(chan int, 10) // channel with a buffer size of 10 +m := make(map[string]int, 100) // map with initial space for approximately 100 elements ++ +
+Calling make with a map type and size hint n will
+create a map with initial space to hold n map elements.
+The precise behavior is implementation-dependent.
+
+The built-in function new takes a type T,
+allocates storage for a variable of that type
+at run time, and returns a value of type *T
+pointing to it.
+The variable is initialized as described in the section on
+initial values.
+
+new(T) ++ +
+For instance +
+ +
+type S struct { a int; b float64 }
+new(S)
+
+
+
+allocates storage for a variable of type S,
+initializes it (a=0, b=0.0),
+and returns a value of type *S containing the address
+of the location.
+
Two built-in functions, panic and recover,
@@ -7655,6 +7660,7 @@ accept arbitrary argument types, but printing of boolean, numeric, and string
types must be supported.