[RFC] std.experimental.concepts

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 25 06:41:27 PDT 2015


On 7/24/15 7:13 PM, deadalnix wrote:
> On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:
>> I put up a PR for phobos awhile ago for concepts as a library to kind
>> of start the discussion around concepts.   There seemed to be some
>> interest around the PR, so I have rebased it and fixed the formatting.
>>
>> Please take a look:
>> https://github.com/D-Programming-Language/phobos/pull/2627
>>
>> -Shammah
>
> Doing it as a library would miss a lot of the point of concepts :
>   - Compiler can do a fair amount of semantic analysis on template
> before instantiating them. This work is done once rather than repeating
> it a every template instantiation.

Interesting.

>   - It allow for much more clearer error messages. Anyone having to
> maintain some meta code will understand what I'm talking about here.

Agreed, though I would more if "much" were dropped.

>   - It make compile time and runtime polymorphism more alike. I do think
> we'd all agree that Andrei approach to mention template arguments as
> compile time arguments and go from there is a good move. Concept would
> be the same move, but for typing. By reusing common language constructs
> (C++ failed to use that opportunity) for instance.

Meh to that.

Now stack these advantages against the advantages of template 
constraints. It's a landslide.


Andrei


More information about the Digitalmars-d mailing list