Apologies if everyone has lost interest in this thread, but I'm just
catching up after a week away from email.

| > > there's difference in behaviour of how Integers are coerced Ints
| > > between Hugs(98) and ghc.
| > > 
| > >    Prelude> (0x80000000 :: Int)
| > > 
| > >    Program error: {primIntegerToInt 2147483648}
| > > 
| > >    Prelude> (maxBound::Int) + 1
| > >    -2147483648
| > >    Prelude>
| > > 
| > > ghc's conversion of Integers is modulo maxInt, i.e.,
| > > 
| > >    (maxBound :: Int) + 1 == (0x80000000::Int)
| > > 
| > > is True.
| > > 
| > > That's consistent & handy, but whatever the behaviour used, it'd be
| > > oh-so convenient if the two implementations agreed.
| > 
| > I think the current behavior of Hugs is reasonable.
| 
| If you're saying that non-catchable, run-time exceptions are ok,
| I'm not at all sure I agree!

I guess the real problem here is that the Haskell report doesn't
say which of these behaviors is correct.  The problem here will
go away when Hugs and GHC use the same runtime system, but that
doesn't really help, especially for other implementations.  So
perhaps somebody will have to make a choice between the alternatives.

Personally, I'd be inclined to vote for the behavior in Hugs in
grateful recognition of the fact that it was recently very helpful to
me.  I was working on the implementation of the new Haskell Random
library at the time, working with some of Sigbjorn's code in the GHC
version, and using the functions to generate pseudo random numbers
in the range (minBound::Int) to (maxBound::Int).  But instead of the
infinite list that I expected, I got just a few elements, and then
an error much like the one above.  I eventually tracked this down to
a bug in the code of both the Hugs and GHC implementations.  If Hugs
had let the overflow go by silently, then I probably wouldn't have
noticed (after all, it was supposed to be a stream of *random*
numbers :-) and those errors might still be lurking in the distributed
code for both systems.

My point is that, while non-catchable run-time exceptions may be bad,
a program that generates the wrong answers without letting you know is
really a whole lot worse!

All the best,
Mark

Reply via email to