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

Issue 101500044: code review 101500044: spec: receiver declaration is just a parameter declaration (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 10 months ago by gri
Modified:
10 years, 10 months ago
Reviewers:
rsc, iant
CC:
r, rsc, iant, ken2, golang-codereviews
Visibility:
Public.

Description

spec: receiver declaration is just a parameter declaration This CL removes the special syntax for method receivers and makes it just like other parameters. Instead, the crucial receiver-specific rules (exactly one receiver, receiver type must be of the form T or *T) are specified verbally instead of syntactically. This is a fully backward-compatible (and minor) syntax relaxation. As a result, the following syntactic restrictions (which are completely irrelevant) and which were only in place for receivers are removed: a) receiver types cannot be parenthesized b) receiver parameter lists cannot have a trailing comma The result of this CL is a simplication of the spec and the implementation, with no impact on existing (or future) code. Noteworthy: - gc already permits a trailing comma at the end of a receiver declaration: func (recv T,) m() {} This is technically a bug with the current spec; this CL will legalize this notation. - gccgo produces a misleading error when a trailing comma is used: error: method has multiple receivers (even though there's only one receiver) - Compilers and type-checkers won't need to report errors anymore if receiver types are parenthesized. Fixes issue 4496.

Patch Set 1 #

Patch Set 2 : diff -r b3702180c491 https://code.google.com/p/go/ #

Patch Set 3 : diff -r b3702180c491 https://code.google.com/p/go/ #

Patch Set 4 : diff -r b3702180c491 https://code.google.com/p/go/ #

Patch Set 5 : diff -r b3702180c491 https://code.google.com/p/go/ #

Patch Set 6 : diff -r 692a05e07645 https://code.google.com/p/go/ #

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

Messages

Total messages: 9
gri
Hello r@golang.org, rsc@golang.org, iant@golang.org, ken@golang.org (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to ...
10 years, 10 months ago (2014-06-24 19:59:28 UTC) #1
iant
LGTM Note that this requires changing test/fixedbugs/bug299.go.
10 years, 10 months ago (2014-06-24 20:28:37 UTC) #2
gri
On Tue, Jun 24, 2014 at 1:28 PM, <iant@golang.org> wrote: > LGTM > > Note ...
10 years, 10 months ago (2014-06-24 20:36:24 UTC) #3
rsc
LGTM
10 years, 10 months ago (2014-06-24 20:39:02 UTC) #4
rsc
FWIW I think gc implements not just trailing comma but also the parsing of (x ...
10 years, 10 months ago (2014-06-24 20:40:28 UTC) #5
gri
Makes sense. The go/parser does the same. Overall this will just bring the spec more ...
10 years, 10 months ago (2014-06-24 20:42:13 UTC) #6
rsc
CL 110160044 implements this in cmd/gc and fixes test/fixedbugs/bug299.
10 years, 10 months ago (2014-06-24 20:47:22 UTC) #7
rsc
CL 110160044 implements this in cmd/gc and fixes test/fixedbugs/bug299.
10 years, 10 months ago (2014-06-24 20:47:23 UTC) #8
gri
10 years, 10 months ago (2014-06-24 23:25:13 UTC) #9
*** Submitted as https://code.google.com/p/go/source/detail?r=fbd4c26ecc93 ***

spec: receiver declaration is just a parameter declaration

This CL removes the special syntax for method receivers and
makes it just like other parameters. Instead, the crucial
receiver-specific rules (exactly one receiver, receiver type
must be of the form T or *T) are specified verbally instead
of syntactically.

This is a fully backward-compatible (and minor) syntax
relaxation. As a result, the following syntactic restrictions
(which are completely irrelevant) and which were only in place
for receivers are removed:

a) receiver types cannot be parenthesized
b) receiver parameter lists cannot have a trailing comma

The result of this CL is a simplication of the spec and the
implementation, with no impact on existing (or future) code.

Noteworthy:

- gc already permits a trailing comma at the end of a receiver
  declaration:

  func (recv T,) m() {}

  This is technically a bug with the current spec; this CL will
  legalize this notation.

- gccgo produces a misleading error when a trailing comma is used:

  error: method has multiple receivers

  (even though there's only one receiver)

- Compilers and type-checkers won't need to report errors anymore
  if receiver types are parenthesized.

Fixes issue 4496.

LGTM=iant, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://codereview.appspot.com/101500044
Sign in to reply to this message.

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