]> Cypherpunks repositories - gostls13.git/commit
spec: apply method sets, embedding to all types, not just named types
authorRuss Cox <rsc@golang.org>
Wed, 29 Feb 2012 20:54:06 +0000 (15:54 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 29 Feb 2012 20:54:06 +0000 (15:54 -0500)
commit8e38b17a906e7208fe9133cedd154758ae4f717d
treed9b28376431649982ef617e01aff0e69c9a0b32b
parent7aba72baaae64792707076724307f6bdc7fec44f
spec: apply method sets, embedding to all types, not just named types

When we first wrote the method set definition, we had long
discussions about whether method sets applied to all types
or just named types, and we (or at least I) concluded that it
didn't matter: the two were equivalent points of view, because
the only way to introduce a new method was to write a method
function, which requires a named receiver type.

However, the addition of embedded types changed this.
Embedding can introduce a method without writing an explicit
method function, as in:

        var x struct {
                sync.Mutex
        }

        var px *struct {
                sync.Mutex
        }

        var _, _ sync.Locker = &x, px

The edits in this CL make clear that both &x and px satisfy
sync.Locker.  Today, gccgo already works this way; 6g does not.

R=golang-dev, gri, iant, r
CC=golang-dev
https://golang.org/cl/5702062
doc/go_spec.html