https://issues.dlang.org/show_bug.cgi?id=12583

Jonathan M Davis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Jonathan M Davis <[email protected]> ---
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.

In general, I would argue simply for going with #2, because it's less of a
maintenance nightmare, though doing #1 in addition to #2 would catch the cases
when someone fails to do #2. Still, I really think that this problem is simply
an argument for why UFCS should always be used where possible. And personally,
I think that this problem is really the only reason that UFCS is worth having.
All of the other reasons for it that I can think of are purely subjective,
where in this case, it actually solves a real problem to use it.

--

Reply via email to