Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1167)

Issue 5702062: code review 5702062: spec: apply method sets, embedding to all types, not ju... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 1 month ago by rsc
Modified:
13 years, 1 month ago
Reviewers:
CC:
golang-dev, gri, iant, r
Visibility:
Public.

Description

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.

Patch Set 1 #

Patch Set 2 : diff -r 2be444b4df80 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 2be444b4df80 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 4 : diff -r 6ac64dcb6fad https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -2 lines) Patch
M doc/go_spec.html View 1 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 7
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 1 month ago (2012-02-29 16:15:31 UTC) #1
gri
LGTM+++ gri On Wed, Feb 29, 2012 at 8:15 AM, <rsc@golang.org> wrote: > Reviewers: golang-dev_googlegroups.com, ...
13 years, 1 month ago (2012-02-29 16:24:52 UTC) #2
rsc
Ian corrected me about gccgo: this new spec is exactly what gccgo already does. I ...
13 years, 1 month ago (2012-02-29 16:27:50 UTC) #3
iant
LGTM
13 years, 1 month ago (2012-02-29 16:38:53 UTC) #4
gri
http://codereview.appspot.com/5702062/diff/4/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/5702062/diff/4/doc/go_spec.html#newcode681 doc/go_spec.html:681: The method set of any other type <code>T</code> I ...
13 years, 1 month ago (2012-02-29 17:49:32 UTC) #5
r
LGTM agree with gri, but in a second CL is fine and maybe better. http://codereview.appspot.com/5702062/diff/4/doc/go_spec.html ...
13 years, 1 month ago (2012-02-29 20:44:18 UTC) #6
rsc
13 years, 1 month ago (2012-02-29 20:54:12 UTC) #7
*** Submitted as http://code.google.com/p/go/source/detail?r=b1f0c3b7a935 ***

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
http://codereview.appspot.com/5702062
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b