Constraints & Concepts [Was: Re: C++0x news]

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Mar 15 10:18:50 PDT 2010


On 03/15/2010 11:30 AM, bearophile wrote:
> Walter Bright:
>
>> Here's a comparison I did of C++0x proposed features and D a while
>> back. It's out of date and incomplete, but it's a reasonable
>> overview: http://www.digitalmars.com/d/2.0/cpp0x.html I suppose I
>> need to revisit it now that C++0x is nearing completion.
>
> In the past I didn't understand the section about Concepts of that
> page , now I am understanding most of it, thanks to this very nice
> article that explains the semantics and usefulness of concept maps:
> http://www.devx.com/SpecialReports/Article/38864/1954?pf=true This
> article has let me understand why concept maps are much more powerful
> (and probably more useful) than D template Constraints.

One man's trash may be another man's treasure, but I think it would be
unproductive to build from a feature that was analyzed at length and
then explicitly rejected by another language, at great cost. To effect
that, you'd have to understand the reasons that made concepts unsuitable
for C++0x and then work out ways to make concepts work for D.

Detecting mistaken use of concepts is practically very easy - just write 
a type that implements the concept vacuously and then instantiate the 
tested template against it in a unittest. I sometimes do that to test my 
range-based code.


Andrei



More information about the Digitalmars-d mailing list