Mixed int/BigInt foreach interval
Jonathan M Davis
jmdavisProg at gmx.com
Mon Sep 26 14:25:53 PDT 2011
On Monday, September 26, 2011 14:13 Andrej Mitrovic wrote:
> On 9/26/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > I think that we need to be _very_ careful about the implications of
> > making isIntegral and other similar traits functions work with
> > non-primitive types. There could _easily_ be code which assumes that
> > it's going to get primitive types when isIntegral is true.
>
> Not *there easily could be* but *there is*. At least in my code..
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
More information about the Digitalmars-d
mailing list