Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
Thanks Ivan. Good to know this. So the answer to my question is just about, like Ian said, confusion for readers? Am Mi., 23. Jan. 2019 um 12:15 Uhr schrieb Ivan Fraixedes : > Perhaps > > There is a handy exception, though. When the value is addressable, the >> language takes care of the

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Ivan Fraixedes
Perhaps There is a handy exception, though. When the value is addressable, the > language takes care of the common case of invoking a pointer method on a > value by inserting the address operator automatically. In our example, the > variable b is addressable, so we can call its Write method

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
Why is that a problem? I can indeed call it on value (at line 20). I got result: > > hello > hello > Program exited. > > I am now more confusing when I come to https://golang.org/doc/faq#different_method_sets. Am Mi., 23. Jan. 2019 um 06:47 Uhr schrieb Andrei Avram < andrei.avram@gmail.com>:

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
On the other side maybe confusion on the part of code writers if they use pointer receiver because of consistency instead of needing it? Am Mi., 23. Jan. 2019 um 00:01 Uhr schrieb Ian Lance Taylor : > On Tue, Jan 22, 2019 at 1:59 PM Xinhu Liu wrote: > > > > In "A Tour of Go" I read: > > > >> In

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 1:59 PM Xinhu Liu wrote: > > In "A Tour of Go" I read: > >> In general, all methods on a given type should have either value or pointer >> receivers, but not a mixture of both. > > > But why not? > > Methods having value receiver can be called by both value type and