From: Robert Griesemer
@@ -490,6 +490,7 @@ The method set of the corresponding pointer type
*T
is the set of all methods with receiver *T or T
(that is, it also contains the method set of T).
Any other type has an empty method set.
+In a method set, each method must have a unique name.
The static type (or just type) of a variable is the @@ -855,7 +856,7 @@ func (n int) (func (p* T))
-An interface type specifies a method set called its interface.
+An interface type specifies a method set called its interface.
A variable of interface type can store a value of any type with a method set
that is any superset of the interface. Such a type is said to
implement the interface. An interface value may be nil.
@@ -864,10 +865,15 @@ that is any superset of the interface. Such a type is said to
InterfaceType = "interface" "{" [ MethodSpecList ] "}" .
MethodSpecList = MethodSpec { ";" MethodSpec } [ ";" ] .
-MethodSpec = identifier Signature | InterfaceTypeName .
+MethodSpec = MethodName Signature | InterfaceTypeName .
+MethodName = identifier .
InterfaceTypeName = TypeName .
++As with all method sets, in an interface type, each method must have a unique name. +
+
// A simple File interface
interface {
@@ -935,8 +941,7 @@ as the File interface.
An interface may contain an interface type name T
in place of a method specification.
-In this notation, T must denote a different interface type
-and the effect is equivalent to enumerating the methods of T explicitly
+The effect is equivalent to enumerating the methods of T explicitly
in the interface.
@@ -1766,7 +1771,6 @@ which is a function with a receiver.
MethodDecl = "func" Receiver MethodName Signature [ Body ] .
Receiver = "(" [ identifier ] [ "*" ] BaseTypeName ")" .
-MethodName = identifier .
BaseTypeName = identifier .
@@ -3010,55 +3014,73 @@ Conversion = LiteralType "(" Expression ")" .
-The following conversion rules apply:
+In general, a conversion succeeds if the value of x is
+assignment compatible with type T,
+or if the value would be assignment compatible with type T if the
+value's type, or T, or any of their component types were unnamed.
+Usually, such a conversion changes the type but not the representation of the value
+of x and thus has no run-time cost.
T.
-T if the value's type, or T, or any of their component
-types were unnamed.
-
+Specific rules apply to conversions where T is a numeric or string type.
+These conversions may change the representation of a value and incur a run-time cost.
+
+If the value is a signed quantity, it is
sign extended to implicit infinite precision; otherwise it is zero
extended. It is then truncated to fit in the result type's size.
For example, if x := uint16(0x10F0), then uint32(int8(x)) == 0xFFFFFFF0.
The conversion always yields a valid value; there is no indication of overflow.
-
x of type float32
+may be stored using additional precision beyond that of an IEEE-754 32-bit number,
+but float32(x) represents the result of rounding x's value to
+32-bit precision. Similarly, x + 0.1 may use more than 32 bits
+of precision, but float32(x + 0.1) does not.
+In all conversions involving floating-point values, if the result type cannot +represent the value the conversion succeeds but the result value is +implementation-dependent. +
+ +string(0x65e5) // "\u65e5" == "æ¥" == "\xe6\x97\xa5"-
nil, the result is the empty string.
-string([]int{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "ç½éµ¬ç¿"
+string([]int{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "ç½éµ¬ç¿"
+
nil,
the result is the empty string.
@@ -3066,7 +3088,7 @@ the result is the empty string.
string([]byte{'h', 'e', 'l', 'l', 'o'}) // "hello"
There is no linguistic mechanism to convert between pointers and integers. @@ -3152,7 +3174,15 @@ overflow etc. errors being caught. When evaluating the elements of an assignment or expression, all function calls, method calls and communication operations are evaluated in lexical left-to-right -order. Otherwise, the order of evaluation is unspecified. +order. +
+ +
+Floating-point operations within a single expression are evaluated according to
+the associativity of the operators. Explicit parentheses affect the evaluation
+by overriding the default associativity.
+In the expression x + (y + z) the addition y + z
+is performed before adding x.
@@ -4132,7 +4162,7 @@ guaranteed to stay in the language. They do not return a result.
-Call Behavior +Function Behavior print prints all arguments; formatting of arguments is implementation-specific println like print but prints spaces between arguments and a newline at the end