Please go ahead, Tim. I’m not really worried about credit for one sentence. You can mention me in the comments if you’d like.
Gregg On Tuesday, February 6, 2018 at 1:11:10 AM UTC-7, thec...@netflix.com wrote: > > Hey Gregg > > I think that would make it more clear and looks great. I wouldn't want to > take credit for your copy, but I'd be happy to open an issue / PR with this > change. I'm not sure how to best attribute it to you. > > Cheers! > -Tim > > On Monday, February 5, 2018 at 2:35:47 PM UTC-8, Gregg Townsend wrote: >> >> 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> 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. >>>> 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.