Extending Base methods with same name, completely different meaning?


#1

There has been a lot of discussion recently, usually very deep and thorough/language designy, about the extension behaviour of methods. Now most of these discussions that I very loosely followed seem to address how the language should be designed for handling the various situations that might occur. Most of them did not lead to a clear conclusion yet I believe.

I am however usually facing the more concrete and trivial situation where I am naming a method like position(atom::Atom), to then see an autocomplete suggestion position(stream::IO) pop up. I always wonder on whether I should then extend Base, or just encapsulate my method only inside the modules that I am using it in. While I think either way works, I’m more inclined to go with the latter. What are the general best practices for this? Or, could I get some feedback of more experienced developers/programmers on what their choice usually is?

offtopic: how can I add a tag that hasn’t been used before? If impossible, could we have a tag: best practices, style guides or something?


#2

I’d go with the latter.


#3

+1 defining the method within your module and not extending base.


#4

Introducing a distinct function or (abstract) type for a something that has disjoint meaning is a decision which I almost never regret. Naming is orthogonal, if the symbols for the right names clash, that’s what we have modules for.