From b1d9ae9406e0217731665da622b7a29fadc3efbd Mon Sep 17 00:00:00 2001
From: Robert Griesemer *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.
+In a method set, each method must have a unique method name.
@@ -1862,11 +1862,13 @@ they can be used to declare local temporary variables (§S
-A function declaration binds an identifier to a function (§Function types).
+A function declaration binds an identifier, the function name,
+to a function.
A method is a function with a receiver.
-A method declaration binds an identifier to a method.
+A method declaration binds an identifier, the method name, to a method.
+It also associates the method with the receiver's base type.
The receiver type must be of the form
+For a base type, the non-blank names of
+methods bound to it must be unique.
+If the base type is a struct type,
+the non-blank method and field names must be distinct.
Function declarations
-FunctionDecl = "func" identifier Signature [ Body ] .
+FunctionDecl = "func" FunctionName Signature [ Body ] .
+FunctionName = identifier .
Body = Block .
@@ -1890,8 +1892,10 @@ func flushICache(begin, end uintptr) // implemented externally
MethodDecl = "func" Receiver MethodName Signature [ Body ] .
Receiver = "(" [ identifier ] [ "*" ] BaseTypeName ")" .
@@ -1900,13 +1904,18 @@ BaseTypeName = identifier .
T
or *T
where
-T
is a type name. T
is called the
-receiver base type or just base type.
-The base type must not be a pointer or interface type and must be
-declared in the same package as the method.
-The method is said to be bound to the base type
-and is visible only within selectors for that type
-(§Type declarations, §Selectors).
+T
is a type name. The type denoted by T
is called
+the receiver base type; it must not be a pointer or interface type and
+it must be declared in the same package as the method.
+The method is said to be bound to the base type and the method name
+is visible only within selectors for that type.
+