My ACCU 2016 keynote video available online

Leontien Smaal via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sat May 21 06:46:07 PDT 2016


On Friday, 20 May 2016 at 19:34:11 UTC, Walter Bright wrote:
> Constraints can address behavior and relationships, concepts do 
> not.

Wow, TIL. That's so clear once said !
There's been several discussion here and even one phobos PR that 
proposes a kind of concepts but I didn't realize before that the 
2 things are different.

The problem I see in D is that the constraints, since they 
prevent to output a good message, are doing both (in a way):

void foo(T)(T t)
if (constraint)
{
     // cannot have the message if constraint fails...
     static assert((checkConcept!T).ok, (checkConcept!T).message);
}

At the language level it would work

void foo(T)(T t) @Concept(CheckerTemplate) // use this to output 
a smart message
if (constraint)
{

}

But really, without changing much what I'd like to see is a DMD 
feature that
would parse and evaluate the constraints to output a message: 
such as

void foo(T)(T t)
if ((a || b) && (a || b))
{
}

> error:(a || b) is false

instead of throwing the whole constraint text in the output.


More information about the Digitalmars-d-announce mailing list