Second CT-Parameter of isRange Predicates

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 2 07:00:23 PST 2015


On 11/02/2015 09:43 AM, Nordlöw wrote:
> On Monday, 2 November 2015 at 14:43:00 UTC, Nordlöw wrote:
>> On Monday, 2 November 2015 at 14:33:44 UTC, Andrei Alexandrescu wrote:
>>>> https://github.com/D-Programming-Language/phobos/pull/3786
>>>
>>> Sent an ICBM its way. -- Andrei
>>
>> Why not extend existing traits with a second `E`-parameter instead of
>> adding a new one?
>
> I think it's very well worth it in terms of expressability.

I'd say it's a minor convenience. Anyhow, integrating tests this way 
depends on how we go about reporting "no match" errors. In the constraint

isForwardRange!R && is(ElementType!R == int)

the compiler could report exactly: "isForwardRange!Widget failed" or 
"is(ElementType!Widget == int) failed". If tests are combined, the 
compiler will only be able to say "isForwardRange!(Widget, int) failed".


Andrei


More information about the Digitalmars-d mailing list