On Friday, 6 October 2017 at 10:56:06 UTC, Guillaume Boucher wrote:

Knowing which function is called when we see its name is very important for reading code. That's why we have those anti hijacking rules: they disallow cases where the compiler knows that the call can be misleading (or can silently break existing code). Another, more tricky case is when there are two functions with the same name in the project you are working on, but only one of them is being imported. If you read the code, you are unsure which one is called. The anti-hijacking rules won't work in that case. Fortunately, a good naming scheme avoids those problems so they are not a big problem in practice.


With respect to overloaded operators, I was trying to make the point above that the anti-hijacking would stay in place. If you wanted to offer two different options for operators, you could put them in separate modules so that you could import one or the other, but not both (which should give an error). I admit it's not super convenient, but it's an option.

Reply via email to