You're right. I do think expanding the section on method sets is worthwhile because that section *seems* to have the complete set of rules. But any addition needs to be clear, concise *and* correct. How about:
... Additionally, an addressable <https://golang.org/ref/spec#Address_operators> value of type T can be used to call methods declared with receiver type *T (see *calls* <https://golang.org/ref/spec#Calls>). On Monday, February 5, 2018 at 2:44:26 PM UTC-7, Axel Wagner wrote: > > That sentence wouldn't be true, though. There is a call-expression > shorthand, but the method does not actually get added to T - so, for example > > var b bytes.Buffer > b.WriteString("foo") // fine > (&b).WriteString("foo") // the same, as it's just syntactic sugare > r := strings.NewReader("foo") > io.Copy(b, r) // error: bytes.Buffer does not implement io.Writer, Write > has pointer receiver > io.Copy(&b, r) // fine > > Method sets are relevant for interface implementation. > > On Mon, Feb 5, 2018 at 10:34 PM, <gtow...@gmail.com <javascript:>> wrote: > >> This issue once puzzled me, too. It would help to add something to the >> spec section on method sets <https://golang.org/ref/spec#Method_sets>. >> I suggest something like this at the very end of the second paragraph: >> >> ... Additionally, if a receiver of type T is *addressable >> <https://golang.org/ref/spec#Address_operators>*, its method set is >> effectively extended to include the method set of *T (see *calls >> <https://golang.org/ref/spec#Calls>*). >> >> >> On Monday, February 5, 2018 at 12:53:32 PM UTC-7, Paul Jolly wrote: >>> >>> >>> Take a look at https://golang.org/ref/spec#Calls: >>> >>> "A method call x.m() is valid if the method set of (the type of) x >>> contains m and the argument list can be assigned to the parameter list of >>> m. If x is addressable and &x's method set contains m, x.m() is shorthand >>> for (&x).m()" >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.