Expressing range constraints in CNF form

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 11 17:07:41 PDT 2017


On 6/11/17 12:35 PM, Stanislav Blinov wrote:
> On Sunday, 11 June 2017 at 16:28:23 UTC, Timon Gehr wrote:
>
>> I'd prefer
>>
>> bool msg(bool constraint, string message){ return constraint; }
>>
>> This does not require the compiler to dive into a branch it wouldn't
>> consider otherwise, and the pairing of constraint to message is less
>> ad-hoc.
>
> Where were you while Steven was destroying me? :)
>
> http://forum.dlang.org/thread/mcxeymbslqtvfijxirmy@forum.dlang.org

Heh, I both like the idea of switching the constraints to something that 
identifies easily a single test of the constraint instead of a lambda 
that can fail for any number of reasons, and also think we still do not 
need a message. i.e.:

is(typeof(lvalueOf!R.front)) && "must support front"

"must support front" seems pretty obvious from the test.

-Steve


More information about the Digitalmars-d mailing list