On 03/24/2017 09:20 PM, st ov wrote:
> Is it idiomatic to mix-&-match pointer and value method receivers for
> a given type? or in *_general_*, if a single method requires a 
> pointer receiver than *all methods* should take a pointer, regardless
> if a value receiver is appropriate?
> 
> For example, should Foo.SetVal also be a pointer receiver even though
> a value receiver would be acceptable?

IMHO this decision should be made exactly the way you would decide if
any other parameter to a function is a pointer. In fact, I think
function receivers are equivalent to passing an additional parameter to
a function. Someone please correct me if I'm wrong.

Particularly: Do you plan to modify the receiver and is the receiver so
large that copying it would be cumbersome.

I don't think there is a hard rule that if you make one receiver a
pointer then all of them must be (or vice versa).

-ayan

-- 
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.

Reply via email to