[Hat] Thoughts, Int vs Integer

Neil Mitchell ndmitchell at gmail.com
Sat Jun 24 16:11:26 EDT 2006


Hi,

> > 1) big_number * 2 will never overflow, which will give a different
> > semantics. Personally this sounds like a good idea, and having a
> > hat-overflow tool to detect when an Integer goes above 2^31 would
> > probably be a useful addition. I don't consider this change to be all
> > that bad, since its compatible with the Haskell98 report (I think).
>
> The basic problem with this is that the bug may well be that an Int
> is overflowing... You don't want the bug to not manifest it's self in
> the self tracing version.

If we assume that most Haskell numbers are below 2 billion - both Int
and Integer, then its easy enought to detect all the places where a
number exceeds this in the trace. I suspect that for most programs
this will be never. If it does occur, I suspect it will be very rare,
and all these occurences can be listed, which would directly track
down the bug really quickly (faster than with the current Hat tools).
The theoretical "hat-overflow" tool can be written which does this.

I suspect a bigger problem would be where the code for an Int instance
is dubious, since that is actually a completely different code path.
But again, I guess this happens really really rarely. I guess most
Int/Integer instances are in the standard libraries, so relatively
safe.

To be clear, because of the semantic changes associated with this
approach, this should be a configurable option.

Thanks

Neil


More information about the Hat mailing list