The Go programming language
Go to file
Robert Griesemer 40818cfe1c spec: method selectors don't auto-deref named pointer types
Language clarification.

The existing rules for selector expressions imply
automatic dereferencing of pointers to struct fields.
They also implied automatic dereferencing of selectors
denoting methods. In almost all cases, such automatic
dereferencing does indeed take place for methods but the
reason is not the selector rules but the fact that method
sets include both methods with T and *T receivers; so for
a *T actual receiver, a method expecting a formal T
receiver, also accepts a *T (and the invocation or method
value expression is the reason for the auto-derefering).

However, the rules as stated so far implied that even in
case of a variable p of named pointer type P, a selector
expression p.f would always be shorthand for (*p).f. This
is true for field selectors f, but cannot be true for
method selectors since a named pointer type always has an
empty method set.

Named pointer types may never appear as anonymous field
types (and method receivers, for that matter), so this
only applies to variables declared of a named pointer
type. This is exceedingly rare and perhaps shouldn't be
permitted in the first place (but we cannot change that).

Amended the selector rules to make auto-deref of values
of named pointer types an exception to the general rules
and added corresponding examples with explanations.

Both gc and gccgo have a bug where they do auto-deref
pointers of named types in method selectors where they
should not:

See http://play.golang.org/p/c6VhjcIVdM , line 45.

Fixes #5769.
Fixes #8989.

LGTM=r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/168790043
2014-11-11 13:19:47 -08:00
api unicode: strconv: regexp: Upgrade to Unicode 7.0.0. 2014-08-18 20:26:10 +02:00
doc spec: method selectors don't auto-deref named pointer types 2014-11-11 13:19:47 -08:00
include liblink: require DATA lines to be ordered by offset, with no overlap 2014-10-14 23:25:12 -04:00
lib all: use golang.org/x/... import paths 2014-11-10 09:15:57 +11:00
misc cmd/dist: remove old misc/pprof 2014-11-09 20:20:26 -05:00
src cmd/cgo: tweak doc to not show example of passing Go pointer 2014-11-10 08:12:43 -08:00
test test: fix nacl build 2014-11-09 21:10:49 -05:00
.hgignore .hgignore: delete some dregs 2014-09-25 17:30:12 -07:00
.hgtags tag go1.4beta1 2014-10-30 12:33:57 +11:00
AUTHORS A+C: add Benoit Sigoure (individual CLA) 2014-11-01 08:27:55 -07:00
CONTRIBUTORS A+C: add Benoit Sigoure (individual CLA) 2014-11-01 08:27:55 -07:00
favicon.ico godoc: update favicon 2012-10-11 17:02:36 +11:00
LICENSE doc: update licensing text one more time 2012-03-27 15:09:13 +11:00
PATENTS LICENSE: separate, change PATENTS text 2010-12-06 16:31:59 -05:00
README README: Fix installation instructions 2013-11-20 13:47:37 -08:00
robots.txt godoc: serve robots.txt raw 2011-02-19 05:46:20 +11:00

This is the source code repository for the Go programming language.  

For documentation about how to install and use Go,
visit http://golang.org/ or load doc/install-source.html
in your web browser.

After installing Go, you can view a nicely formatted
doc/install-source.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install/source.

Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.

--

Binary Distribution Notes

If you have just untarred a binary Go distribution, you need to set
the environment variable $GOROOT to the full path of the go
directory (the one containing this README).  You can omit the
variable if you unpack it into /usr/local/go, or if you rebuild
from sources by running all.bash (see doc/install.html).
You should also add the Go binary directory $GOROOT/bin
to your shell's path.

For example, if you extracted the tar file into $HOME/go, you might
put the following in your .profile:

    export GOROOT=$HOME/go
    export PATH=$PATH:$GOROOT/bin

See doc/install.html for more details.