Bolts 1.4 - added experimental signatures for D

aliak something at something.com
Wed Feb 19 14:20:18 UTC 2020


On Friday, 14 February 2020 at 21:33:01 UTC, aliak wrote:
> Hi,
> [...]
>
> Cheers,
> - ali

Ok, you can now model an actual input range with most of it's 
caveats:

interface InputRange(T) {
     @property bool empty();
     @property T front();
     @ignoreAttributes void popFront();
}

struct MyRange {
     mixin Models!(InputRange!int);
}

source/bolts/experimental/signatures.d(341,5): Error: static 
assert:  "Type MyRange does not comply to signature 
InputRange!(int)
   Missing identifier empty of type bool.
   Missing identifier front of type int.
   Missing identifier popFront of function type void().
   source/bolts/experimental/signatures.d(8): <-- Signature 
InputRange!(int) defined here.
   source/bolts/experimental/signatures.d(15): <-- Checked here."

To fix the errors you'd need a name called empty that returns a 
bool (i.e. is a member variable or a property function). Same 
with front. And for popFront it can be a function with whichever 
attributes attached to it.

Not sure what to do with a range model that has "ref T front". 
Maybe an @ignoreRefness attribute?

Cheers


More information about the Digitalmars-d-announce mailing list