Just sayin', fwiw...
Nick Sabalausky (Abscissa)
SeeWebsiteToContactMe at semitwist.com
Thu May 16 19:25:14 UTC 2019
On 5/16/19 1:47 PM, H. S. Teoh wrote:
>
> Why should the user care that find's implementation treats strings and
> non-string separately? That's an irrelevant implementation detail that
> should be hidden inside the function body. Exposing it as a sig
> constraint in a public-facing API breaks encapsulation, and is an
> anti-pattern.
>
You make a good point.
> I've already repeated this many, many times, but there still remains a
> lot of Phobos/druntime code written according to this anti-pattern,
> including a recent example of hashOf being a *21*-function overload set
> in druntime. Insane!! Glancing through those overloads reveals that
> the sig constraints are all implementation details, i.e., they should
> NOT be sig constraints in a public-facing API, but static if conditions
> inside the function body dispatching to various different
> implementations.
>
> Abusing overload sets for this purpose is an anti-pattern, and needs to
> stop.
>
Sounds like someone has good qualifications to put together a PR ;)
More information about the Digitalmars-d
mailing list