On Tuesday, 12 March 2013 at 04:34:05 UTC, Walter Bright wrote:
It's interfaces without the vtable[].

It's still solely based on type signatures. D constraints make pretty much anything that can be computed at compile time a testable gate.

Yeah, you're right. That kind of interface syntax doesn't really
lend itself to specifying concepts. So, here's another attempt at
a concept syntax (and functionality):

concept AscendingInfiniteInputRange {
     // 'this' is an instance of a type which implements the
     // AscendingInfiniteInputRange concept given the
     // if-condition below is true:
     if( is(typeof(this.empty) : bool)
     &&  is(typeof(this.front))
     && !is(typeof(this.front) == void)
     &&  is(typeof(this.popFront() == void)
     // testing a compile time evaluable value:
     &&  this.empty == false
     // static members can also be tested:
     &&  typeof(this).infinite == true
     &&  typeof(this).sortedAscending == true )
}

// extending the AscendingInfiniteInputRange concept:
concept AscendingInfiniteForwardRange
       : AscendingInfiniteInputRange
{
     if (is(typeof(this.save) == typeof(this)))
}

// a concept of a 2-dimensional infinite ascending slope:
concept InfiniteSlope : AscendingInfiniteForwardRange {
     // 'is' can be used to test if a type implements a concept:
     if (is(typeof(this.front) == AscendingInfiniteForwardRange))
}

Reply via email to