Expressing range constraints in CNF form

Sebastiaan Koppe via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 12 12:28:46 PDT 2017


On Monday, 12 June 2017 at 17:35:59 UTC, David Gileadi wrote:
> On 6/11/17 1:32 PM, Sebastiaan Koppe wrote:
>
>> What about using ddoc?
>> 
>> enum bool isInputRange(R) =
>>      is(typeof((ref R r) => r)) /// must be copyable
>>      && is(ReturnType!((R r) => r.empty) == bool) /// must 
>> support bool empty
>>      && is(typeof(lvalueOf!R.front)) /// must support front
>>      && is(typeof(lvalueOf!R.popFront)) /// must support back
>
> If there's going to be compiler magic, this seems like a 
> sensible syntax--documenting constraints is a good idea anyway, 
> particularly for those of us who aren't is-expression masters.

Yeah, I had meant to mention the compiler magic involved. I 
suppose the magic is far less than anything else though, since 
the compiler already associates surrounding docs to code (right?).


More information about the Digitalmars-d mailing list