www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D2 Feature?

reply Patrick Kreft <patrick_kreft gmx.net> writes:
I want to know  that concept like C++0x is planing for D?
Would improve policy-based class design ^^
Regards
Patrick Kreft
Oct 09 2007
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Patrick Kreft wrote:
 I want to know  that concept like C++0x is planing for D?
 Would improve policy-based class design ^^
 Regards
 Patrick Kreft

I don't think so, but if I remember correctly, someone already implemented C++0x style concepts as a library (sorry; can't seem to find the post at the moment). -- Daniel
Oct 09 2007
next sibling parent reply jcc7 <technocrat7 gmail.com> writes:
== Quote from Daniel Keep (daniel.keep.lists gmail.com)'s article
 Patrick Kreft wrote:
 I want to know  that concept like C++0x is planing for D?
 Would improve policy-based class design ^^
 Regards
 Patrick Kreft

implemented C++0x style concepts as a library (sorry; can't seem to find the post at the moment). -- Daniel

Are you guys talking about "futurism"? http://www.dsource.org/projects/futurism http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6762 http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6827
Oct 10 2007
parent Patrick Kreft <patrick_kreft gmx.net> writes:
jcc7 schrieb:
 == Quote from Daniel Keep (daniel.keep.lists gmail.com)'s article
 Patrick Kreft wrote:
 I want to know  that concept like C++0x is planing for D?
 Would improve policy-based class design ^^
 Regards
 Patrick Kreft

implemented C++0x style concepts as a library (sorry; can't seem to find the post at the moment). -- Daniel

Are you guys talking about "futurism"? http://www.dsource.org/projects/futurism http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6762 http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=6827

Interfaces have to implemented by an class template. If i didnt implemented it, the compiler will give me a warning.
Oct 10 2007
prev sibling parent Reiner Pope <some address.com> writes:
Daniel Keep wrote:
 Patrick Kreft wrote:
 I want to know  that concept like C++0x is planing for D?
 Would improve policy-based class design ^^
 Regards
 Patrick Kreft

I don't think so, but if I remember correctly, someone already implemented C++0x style concepts as a library (sorry; can't seem to find the post at the moment). -- Daniel

I don't know if this is what you mean, but a while ago when concepts were discussed, I posted a proof-of-concept ( :-) )implementation: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=51849 I haven't looked at it recently, but from memory, it allows both sides of concept checking (checking that your template only uses the features specified in the concept, and checking that the template parameters match the required concept), albeit somewhat verbosely, by effectively writing a one-line "static unittest" which instantiates your template with the minimum requirements, and also single static assert in the template requiring that the parameter matches the concept. At the time, I didn't think overloading was possible, because the compile would simply fail if the static assert failed. However, Sean Kelly (I think) recently posted a clever way to get around this: void foo(T, bool TMatches : bool = MatchesConcept!(T))(T t) {...} This is a good step further, as it allows overloads, but it doesn't handle the case where two overloads match, yet one should be more specialised than the other. For instance, if one template works on the Iterator concept and one works on the RandomAccessIterator concept, it should choose the RandomAccessIterator, but currently it just gives an ambiguity error. Overall, though, I think a library implementation would be very verbose in comparison to C++ (or Haskell type-classes), the fundamental reason being the need to write a "static unittest" for every template and a Sean Kelly-inspired bool specialisation for every concept-checked template parameter. When you consider that this checking should ideally be written for every templated function you write, it becomes excessive. To make it nice, some form of compiler assistance is required. -- Reiner
Oct 11 2007