Now that's a DIP that could use some love

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Thu Sep 17 20:28:21 UTC 2020


On 9/17/20 3:58 PM, H. S. Teoh wrote:
> On Thu, Sep 17, 2020 at 01:16:13PM -0600, Jonathan M Davis via Digitalmars-d 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.
> [...]
>> It's like commenting every line to say what it does.
> 
> Exactly, this breaks DRY.

Not at all! What in the world...? The constraint is the mechanics, it 
often says little about the high-level requirements. Granted, sometimes 
the mechanism is simple enough to be sufficiently evocative. But would 
you really like the compiler error messages in terms of the LR step that 
failed?

It's a funny coincidence this thread is going in parallel with a couple 
of other developments:

* `each` has literally inscrutable constraints (I say "literally" 
because their documentation is not visible)
* `equals` also has nigh unreadable constraints, see 
https://github.com/dlang/phobos/pull/7635/files

If you (cut and) DRY that stuff, I'll eat it.

I found these in literally the first two files I looked at in Phobos.

I can't believe I need to argue this stuff. DRY? No, it's wet like a 
drowned rat.


More information about the Digitalmars-d mailing list