Now that's a DIP that could use some love

Jonathan M Davis newsgroup.d at
Thu Sep 17 20:02:40 UTC 2020

On Thursday, September 17, 2020 1:34:49 PM MDT Andrei Alexandrescu via 
Digitalmars-d wrote:
> On 9/17/20 3:16 PM, Jonathan M Davis wrote:
> > Honestly, IMHO, that makes the code far worse. You're just repeating the
> > constraints in plain English, which requires more than double the code for
> > each constraint and doesn't really make the error messages much easier to
> > understand IMHO - especially when the constraints are already using traits
> > that make what they're doing clear.
> This has got to be the ultimate in reverse psychology. Picture this: I
> set out to save Walter some work. I took what seemed a motherhood and
> apple pie argument - I mean, who in the world would argue against better
> error messages? Yes, in Queen's English! It turns out, those can be found.
> Now imagine I wrote this instead:
> How about we do some DIP cleanup? All those dead and moribund DIPs
> laying around. I suggest we start with
> - it really does nothing else but
> repeat the constraints in natural language. There's also been
> improvements in how the compiler displays errors. I propose we just chop
> that DIP.

I really don't think that repeating a constraint in English improves the
error messages particularly, and as shown in your example, it gets pretty
verbose. In practice, I've never seen reading the constraint as the problem
when dealing with a failed template constraint. The constraint itself
already explains itself in code. The problem is figuring out which part is
failing and why, and that usually requires digging deeper. IMHO, _that_ is
the problem that would be useful to solve if we want to make it easier to
solve problems with failed template constraints. Simply repeating the
constraint in English doesn't do that. The only part of that DIP that looks
useful to me is the fact that it breaks up the constraint so that you can
see which part failed, but simply having the compiler break out the
constraint along each && clause and print whether it was true or false would
do the same thing without making a lot of template constraints more verbose.

I'd be fine with the DIP being chopped. IMHO, it doesn't realy help with the
real problem.

- Jonathan M Davis

More information about the Digitalmars-d mailing list