Mixed int/BigInt foreach interval

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 26 19:06:30 PDT 2011


On 9/26/11 6:49 PM, bearophile wrote:
> Jonathan M Davis:
>
>> Why is it bad? isIntegral was specifically designed for testing that a type was
>> one of byte, ubyte, short, ushort, int, uint, long, and ulong, and that's
>> exactly what it's doing.
>
> Going back to my original post, is changing the semantics of isIntegral enough to allow code like this to compile and run?
>
> foreach (i; 1 .. BigInt(10)) {}
>
> Bye,
> bearophile

Well isIntegral was designed indeed for primitive integral types. The 
problem with having isIntegral!BigInt dilutes the meaning of isIntegral 
because there are significant differences between

Without having thought a lot of this, my impression is we need a sort of 
isMonoid!(T, "+", 0) as a guard for iota.


Andrei


More information about the Digitalmars-d mailing list