Mixed int/BigInt foreach interval
Jonathan M Davis
jmdavisProg at gmx.com
Mon Sep 26 18:38:11 PDT 2011
On Monday, September 26, 2011 18:33:22 Mehrdad wrote:
> On 9/26/2011 2:25 PM, Jonathan M Davis wrote:
> > What I probably meant to say was "Code could easily assume that..."
> > but you get the idea. Certainly, there's no question that there's code
> > out there that would be broken by such a change - including code in
> > Phobos. So, we need to be very careful about any such changes. But
> > since it would be easy to have a template constraint check
> > if(isIntegral!T || is(Unqual!T == BigInt)) I don't see much benefit in
> > making isIntegral return true for BigInt anyway. BigInt is _not_ the
> > same as the built-in integral types. Code which uses integral types
> > could easily not work with BigInt. Yes, there is plenty of code that
> > could work with both, but it needs to be designed with that level of
> > genericness in mind, and much of the code using isIntegral is _not_. -
> > Jonathan M Davis
>
> IMHO that's a pretty bad constraint check.
>
> What it should instead be is something along the lines of:
>
> isIntegral!T && isPrimitive!T
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.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list