Constraints

dennis luehring dl.soluz at gmx.net
Thu May 10 03:52:57 PDT 2012


Am 10.05.2012 11:55, schrieb "İbrahim Gökhan YANIKLAR" 
<yanikibo at gmail.com>":
> Concepts provide us a common interface for structs, classes,
> interfaces, even arrays.

but for what then interfaces are?
but what concept should for example an array have? the typecheck of the 
array itself???

> Concepts can be practically extended.

if your world is very OOPish orientated - but the generic world
keeps itself away from "derived functionality"

> Concepts can be used for template specialization and as compile
> time constraints and as a static interface.

D current concepts can also be used like that - you just implement a 
very lossy tied boolean expression (direct or as function) and thats it 
- that is pure generic thinking

you don't need to be part of an hierarchy - just have the shape that is 
needed

> Also we can use concepts as traits like that:
>
> static if (is(T : Concept)) { }
>
> instead of
>
> static if (satisfiesConcept!T) { }

but the type should only satisfy the concept
its does not need to derived from that - think of the thoundsand
of specialised concept-classes that will occure (for example in phobos)


More information about the Digitalmars-d mailing list