Constraints

"İbrahim Gökhan "İbrahim Gökhan
Thu May 10 04:12:10 PDT 2012


> but for what then interfaces are?

Interfaces are for classes, and provides a virtual interface.
Concepts are for all, and provides a generic, static interface. 
Not to use as base class.

> but what concept should for example an array have? the 
> typecheck of the array itself???

For example CInputRange can be used for arrays, or other ranges 
that did not derived from CInputRange. It's only have some 
constraints.

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

Not derived functionality, derived constraints. When you derive a 
concept you only compose the constraints by AND logic.

> 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)

You can use a different syntax instead of inheritance.
Simple things should be done by using template constraints. I did 
not offer to remove template constraints. So if you need an 
interface like Ranges you use concepts, if you don't need an 
interface you use template constraints.


More information about the Digitalmars-d mailing list