Better error messages - from reddit

Johannes Pfau nospam at example.com
Fri Mar 8 08:19:41 UTC 2019


Am Fri, 08 Mar 2019 05:46:01 +0000 schrieb Nicholas Wilson:

> On Thursday, 7 March 2019 at 22:09:29 UTC, Johannes Pfau wrote:
>> The DIP seems kind of intrusive to me. And Parsing a DNF
> 
> The DIP formalises a constraint in a _CNF_, not DNF.

You're right of course, I guess I was too tired when I wrote that.

>> form has one major drawback: For quite some time now we actually
>> advised people to refactor their constraints into external helper
>> functions, in order to have nicer ddoc. E.g.
>> isDigest!X instead of isOutputRange!X && ...
> 
> Yes, but this is for a single concept for a single parameter. Real
> constraints deal with multiple parameters and conjunctions and
> disjunction of concepts, hence the CNF formalisation. The rest of what
> you describe is great, but completely orthogonal.
> 
> I have made this comment before:
> https://github.com/dlang/DIPs/pull/131#issuecomment-416555780
> 
>> So now, we'd have to recommend the exact opposite.
> 
> This follows only for a single parameter.

OK, I see. For multiple parameters a CNF form is indeed the natural 
description. However, the DIP probably wouldn't be needed with 
traits(constraintsCheck) as multiple error reporting would also work with 
a CNF of implements!T or other constraints. One thing a simple 
traits(constraintsCheck) can probably not handle easily is pointing out 
which of the implements!T calls caused the errors, though if we detect CNF 
in the compiler that could work. Really difficult are more complicated 
constructs such as (isSomething!(A, B) || isSomething!(A, C)). Here 
traits(constraintsCheck) would produce all messages for both checks if 
both fail.

-- 
Johannes


More information about the Digitalmars-d mailing list