diff --git a/doc/go_spec.html b/doc/go_spec.html index 2c6fcd1526..57f2db7402 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -15,7 +15,6 @@ TODO [ ] need explicit language about the result type of operations [ ] should probably write something about evaluation order of statements even though obvious -[ ] review language on implicit dereferencing --> @@ -2324,7 +2323,6 @@ Point{1, 2} m["foo"] s[i : j + 1] obj.color -math.Sin f.p[i].x() @@ -2332,7 +2330,9 @@ f.p[i].x()
-A primary expression of the form
+For a primary expression x
+that is not a package name, the
+selector expression
@@ -2340,17 +2340,20 @@ x.f
-denotes the field or method f of the value denoted by x
-(or sometimes *x; see below). The identifier f
-is called the (field or method)
-selector; it must not be the blank identifier.
-The type of the expression is the type of f.
+denotes the field or method f of the value x
+(or sometimes *x; see below).
+The identifier f is called the (field or method) selector;
+it must not be the blank identifier.
+The type of the selector expression is the type of f.
+If x is a package name, see the section on
+qualified identifiers.
A selector f may denote a field or method f of
a type T, or it may refer
-to a field or method f of a nested anonymous field of
-T.
+to a field or method f of a nested
+anonymous field of T.
The number of anonymous fields traversed
to reach f is called its depth in T.
The depth of a field or method f
@@ -2359,9 +2362,11 @@ The depth of a field or method f declared in
an anonymous field A in T is the
depth of f in A plus one.
The following rules apply to selectors:
+x of type T or *T
@@ -2373,18 +2378,26 @@ If there is not exactly one f<
with shallowest depth, the selector expression is illegal.
x of type I
-where I is an interface type,
-x.f denotes the actual method with name f of the value assigned
-to x if there is such a method.
-If no value or nil was assigned to x, x.f is illegal.
+For a variable x of type I where I
+is an interface type, x.f denotes the actual method with name
+f of the value assigned to x.
+If there is no method with name f in the
+method set of I, the selector
+expression is illegal.
x.f is illegal.
x is of pointer or interface type and has the value
+nil, assigning to, evaluating, or calling x.f
+causes a run-time panic.
+
-Selectors automatically dereference pointers to structs.
+Selectors automatically dereference
+pointers to structs.
If x is a pointer to a struct, x.y
is shorthand for (*x).y; if the field y
is also a pointer to a struct, x.y.z is shorthand
@@ -2393,6 +2406,7 @@ If x contains an anonymous field of type *A,
where A is also a struct type,
x.f is a shortcut for (*x.A).f.
For example, given the declarations: