Re: [go-nuts] Re: Constructor return advice

2017-04-21 Thread st ov
Thanks for the confirmation and advice! On Friday, April 21, 2017 at 1:29:02 PM UTC-7, Alan Donovan wrote: > > On 21 April 2017 at 15:26, st ov > wrote: >> >> When deciding between method receivers, any advice on how to choose which >> to use? >> Is it as simple as, when you need to change the

Re: [go-nuts] Re: Constructor return advice

2017-04-21 Thread 'Alan Donovan' via golang-nuts
On 21 April 2017 at 15:26, st ov wrote: > > When deciding between method receivers, any advice on how to choose which > to use? > Is it as simple as, when you need to change the instance pass a pointer, > otherwise pass a value. And then once one method requires a pointer, then > all methods shoul

[go-nuts] Re: Constructor return advice

2017-04-21 Thread st ov
Thanks! So the type's method receiver should be the deciding factor. And method receivers for a type should be either *all* pointers or *all* values. When deciding between method receivers, any advice on how to choose which to use? Is it as simple as, when you need to change the instance pass a

[go-nuts] Re: Constructor return advice

2017-04-21 Thread adonovan via golang-nuts
On Friday, 21 April 2017 12:28:25 UTC-4, st ov wrote: > > In general, is it advisable to return pointers to newly constructed > instances when using constructors? > > Would it matter more for types that don't have members of composite types > slice and maps? > So in the following example, https: