• Robert Griesemer's avatar
    spec: receiver declaration is just a parameter declaration · 187ee2cf
    Robert Griesemer authored
    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 #4496.
    
    LGTM=iant, rsc
    R=r, rsc, iant, ken
    CC=golang-codereviews
    https://golang.org/cl/101500044
    187ee2cf
Name
Last commit
Last update
..
articles Loading commit data...
codewalk Loading commit data...
devel Loading commit data...
gopher Loading commit data...
play Loading commit data...
progs Loading commit data...
asm.html Loading commit data...
cmd.html Loading commit data...
code.html Loading commit data...
contrib.html Loading commit data...
contribute.html Loading commit data...
debugging_with_gdb.html Loading commit data...
docs.html Loading commit data...
effective_go.html Loading commit data...
gccgo_contribute.html Loading commit data...
gccgo_install.html Loading commit data...
go-logo-black.png Loading commit data...
go-logo-blue.png Loading commit data...
go-logo-white.png Loading commit data...
go1.1.html Loading commit data...
go1.2.html Loading commit data...
go1.3.html Loading commit data...
go1.4.txt Loading commit data...
go1.html Loading commit data...
go1compat.html Loading commit data...
go_faq.html Loading commit data...
go_mem.html Loading commit data...
go_spec.html Loading commit data...
help.html Loading commit data...
ie.css Loading commit data...
install-source.html Loading commit data...
install.html Loading commit data...
logo-153x55.png Loading commit data...
root.html Loading commit data...
share.png Loading commit data...
sieve.gif Loading commit data...
tos.html Loading commit data...