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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Mar 22 12:52:53 PDT 2010


On 03/22/2010 02:09 PM, bearophile wrote:
> Andrei Alexandrescu:
>
>> 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.
>
> I don't know exactly why they have refused Concepts, but to refuse
> them after so many years of developments and discussions (and
> ConceptG++, many nice papers written about their usage, etc) then
> they have good reasons. You are right, better to not go there, even
> if it's seducing stuff.

It's a long story. I think I'd summarize it by saying again: just like 
in chess, in PL design ignoring the whole for the beauty of the part is 
a capital mistake.

>> 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.
>
> Thank you for this interesting suggestion, I'll try it. In the
> meantime I have found a Boost docs page about the same topic, I think
> their 'archetype class' is the same thing you are saying me:
> http://www.boost.org/doc/libs/1_42_0/libs/concept_check/concept_covering.htm

Yah, archetype-based checking was endorsed by Bjarne Stroustrup and 
myself (though my participation was negligible, so really I'm the only 
one claiming credit :o)). That proposal "lost" and concepts as 
ultimately proposed "won". If asked to speculate, I'd say that the other 
approach, if chosen, would have change the state of affairs dramatically.


Andrei



More information about the Digitalmars-d mailing list