3 ms·
> > Avoid unused method receiver names > That's just "don't create a non-static method if you don't use 'this'" in other languages with classes. I don't think
by tczMUFlmoNk 2y ago
> > Avoid unused method receiver names
> That's just "don't create a non-static method if you don't use 'this'" in other languages with classes.
I don't think that's what's meant. It means to write `func (Receiver) Method()` rather than `func (r Receiver) Method()` when you don't use `r`. Sometimes you need this to implement an interface like `error` or `Stringer` and you just don't need instance data.
(I'm no Go apologist but I think "receiver" is a great term. It's clear, it's applies to other languages and paradigms, and it doesn't really have an alternative that I'm aware of.)
- layer8 2y agoThe term “receiver” comes from Smalltalk: http://www.bitsavers.org/pdf/xerox/parc/techReports/SSL-76-6_Smalltalk-72_Instruction_Manual_Mar76.pdf http://www.bitsavers.org/pdf/xerox/parc/techReports/SSL-76-6...
- tczMUFlmoNk 2y agoThat makes sense. I just about figured it would. :-)