3 ms·
Pointer vs value receivers and named returns have so many gotchas that it is not even funny. Lack of magic my ass.
by rochak 3y ago
Pointer vs value receivers and named returns have so many gotchas that it is not even funny. Lack of magic my ass.
- asylteltine 3y agoCan you name any? I have never seen a “gotcha” because it’s just explicit… it’s not like you are surprised by a pointer.
- teeray 3y agoThe way you avoid these are twofold: 1) Use the pointer receiver unless you have a really good reason to do otherwise. 2) Never, ever use named returns. Code can (and should) always be written to not use them.
- ssd532 3y agoCan you elaborate point 2, please?I am wondering how is that related to the issue of pointer and value semantics.