D UFCS anti-pattern
Dmitry Olshansky via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 25 02:35:59 PDT 2014
25-Apr-2014 06:21, Steven Schveighoffer пишет:
> Recently, I observed a conversation happening on the github pull request
> system.
>
> In phobos, we have the notion of output ranges. One is allowed to output
> to an output range by calling the function 'put'.
>
[snip]
>
> The anti-pattern here is using member functions to override or
> specialize UFCS behavior. In this case, we even hook the UFCS call with
> the member function, encouraging the name conflict!
>
> As a possible solution, I would recommend simply change the name of the
> hook, and have the UFCS function forward to the hook. This way, calling
> put(r,...) and r.put(...) is always consistent.
+1
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list