Just sayin', fwiw...

H. S. Teoh hsteoh at quickfur.ath.cx
Fri May 17 18:21:04 UTC 2019


On Thu, May 16, 2019 at 04:20:48PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
> On 5/16/19 6:47 PM, H. S. Teoh wrote:
> 
> > 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.
> > 
> 
> Context is important. I think this code was trying to replace 21
> overloads of TypeInfo calls IIRC. So at least it's better than the
> previous solution.

Instead of replacing 21 overloads of TypeInfo calls with 21 overloads of
hashOf, the refactoring should have been done with a single overload of
hashOf with 21 static if branches.


> Refactoring would probably make sense, but not before you replace
> exactly the existing solution.
[...]

I'm tempted to submit a PR to unify toHash overloads like above. Would
it be accepted?


T

-- 
May you live all the days of your life. -- Jonathan Swift


More information about the Digitalmars-d mailing list