From: Robert Griesemer byte
, which is an alias for uint8
, and
rune
, which is an alias for int32
.
-Conversions
+Explicit conversions
are required when different numeric types are mixed in an expression
or assignment. For instance, int32
and int
are not the same type even though they may have the same size on a
@@ -1348,7 +1348,7 @@ ChannelType = ( "chan" | "chan" "<-" | "<-" "chan" ) ElementType .
The optional <-
operator specifies the channel direction,
send or receive. If no direction is given, the channel is
bidirectional.
-A channel may be constrained only to send or only to receive by
+A channel may be constrained only to send or only to receive by explicit
conversion or assignment.
bool
.
+if it is an untyped boolean value, it is first implicitly converted to type bool
.
The predeclared value nil
cannot be used to initialize a variable
with no explicit type.
@@ -3433,7 +3433,7 @@ For operations involving constants only, see the section on
Except for shift operations, if one operand is an untyped constant -and the other operand is not, the constant is converted +and the other operand is not, the constant is implicitly converted to the type of the other operand.
@@ -3442,7 +3442,7 @@ The right operand in a shift expression must have unsigned integer type or be an untyped constant representable by a value of typeuint
.
If the left operand of a non-constant shift expression is an untyped constant,
-it is first converted to the type it would assume if the shift expression were
+it is first implicitly converted to the type it would assume if the shift expression were
replaced by its left operand alone.
@@ -3645,7 +3645,7 @@ occurs is implementation-specific.
An implementation may combine multiple floating-point operations into a single
fused operation, possibly across statements, and produce a result that differs
from the value obtained by executing and rounding the instructions individually.
-A floating-point type conversion explicitly rounds to
+An explicit floating-point type conversion rounds to
the precision of the target type, preventing fusion that would discard that rounding.
@@ -3907,7 +3907,14 @@ channel is closed and empty.
-Conversions are expressions of the form T(x)
+A conversion changes the type of an expression
+to the type specified by the conversion.
+A conversion may appear literally in the source, or it may be implied
+by the context in which an expression appears.
+
+An explicit conversion is an expression of the form T(x)
where T
is a type and x
is an expression
that can be converted to type T
.
x
can be converted to
type T
if x
is representable
by a value of T
.
-As a special case, an integer constant x
can be converted to a
+As a special case, an integer constant x
can be explicitly converted to a
string type using the
same rule
as for non-constant x
.
@@ -4672,13 +4679,13 @@ to the type of the operand to which it is assigned, with the following special c
bool
.
+ the blank identifier, it is first implicitly converted to type bool
.
-If the switch expression evaluates to an untyped constant, it is first
+If the switch expression evaluates to an untyped constant, it is first implicitly
converted to its default type;
-if it is an untyped boolean value, it is first converted to type bool
.
+if it is an untyped boolean value, it is first implicitly converted to type bool
.
The predeclared untyped value nil
cannot be used as a switch expression.
-If a case expression is untyped, it is first converted
+If a case expression is untyped, it is first implicitly converted
to the type of the switch expression.
For each (possibly converted) case expression x
and the value t
of the switch expression, x == t
must be a valid comparison.
@@ -5881,7 +5888,7 @@ floating-point type and the return type is the complex type
with the corresponding floating-point constituents:
complex64
for float32
arguments, and
complex128
for float64
arguments.
-If one of the arguments evaluates to an untyped constant, it is first
+If one of the arguments evaluates to an untyped constant, it is first implicitly
converted to the type of the other argument.
If both arguments evaluate to untyped constants, they must be non-complex
numbers or their imaginary parts must be zero, and the return value of