Static inheritance (proof of concept)
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 27 10:14:25 PST 2016
On Sat, 27 Feb 2016 13:35:30 +0000, Iakh wrote:
> There was discussion and proposal to extend D with static inheritance:
> http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf@forum.dlang.org
>
> But it could be done just with mixins, UDAs and some rewriting of
> predicates.
>
> Exaple:
>
> @concept!isInputRange()
> struct Range {
> mixin checkConcepts;
>
> int front()
> {
> return 0;
> }
> }
Looks good. I'd prefer to have just the mixin or just the attribute --
the latter being tricky just now.
It'd be just as easy to make it:
struct Range {
mixin ensureConcept!isInputRange;
}
More information about the Digitalmars-d
mailing list