https://issues.dlang.org/show_bug.cgi?id=12583
--- Comment #3 from [email protected] --- (In reply to Jonathan M Davis from comment #2) > I think that having std.range.retro call the member function retro if there > is one is fine, but I should point out that this is a general problem which > is not at all specific to retro. Pretty much _any_ free function can be > replaced with a member function which is more efficient if a user-defined > type has a way of doing the same thing more efficiently. So, to solve this > problem in the general case, I think we have to do one of two things: > > 1. Make it standard policy to have a free function check if there is a > member function which takes the same arguments and then calls that instead > of using its own implementation if such a function exists. > > 2. Make it standard policy to always use UFCS, in which case, the member > function will always be used if it exists. The issue is that 2 can clash with 1, if the type in question has the member function, but not with the correct args. A typical example is `put`: It should *not* be used UFCS: //---- struct S { void put(int){}; } void main() { S s; int[] a; put(s, a); //Fine, put the array a into s. s.put(a); //Nope, don't know how to. } //---- So, if (for some strange reason), I were to add "retro(int)" to my function, but not "retro()", then a UFCS call to "myRange.retro()" would fail. --
