Producing nicer template errors in D libraries

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Apr 11 07:12:33 PDT 2012


On 4/11/12 6:42 AM, Don Clugston wrote:
> Incidentally, when all template constraints fail, the compiler could
> check them all again, and tell you exactly which conditions failed...
>
> Algorithm: We know that:
>
> false = !constraint1() && !constraint2() && !constraint3().
>
> break each constraints into top-level boolean expressions. Then simplify
> (possibly using a BDD).
> easy (but common) example, if constraint1() = !A() && B(), constraint2 =
> !A() && C(), constraint3() == !A() && !B() && !D()
>
> it simplifies to: false = !A().
> So we generate an error only saying that !A() failed.

This would be a major improvement to the compiler.

Andrei




More information about the Digitalmars-d mailing list