[Haskell-cafe] Re: Exception handling in numeric computations

Jonathan Cast jonathanccast at fastmail.fm
Fri Mar 27 13:41:05 EDT 2009

On Fri, 2009-03-27 at 20:38 +0300, Gregory Petrosyan wrote:
> On Fri, Mar 27, 2009 at 7:31 PM, Donn Cave <donn at avvanta.com> wrote:
> > Quoth John Lato <jwlato at gmail.com>,
> >
> >> An exception is caused by some sort of interaction with the run-time
> >> system (frequently a hardware issue).  The programmer typically can't
> >> check for these in advance, but can only attempt to recover after
> >> they've happened.
> >>
> >> An error is some sort of bug that should be fixed by the programmer.
> >
> > I have never felt that I really understood that one.
> Me too :-)
> BTW, John, how often do you encounter _hardware_ issues compared to "errors"?

Can't speak for anyone else, but I usually encounter hardware issues
just before I replace the hardware...

> Is an "out of memory" thing an error or exception?
> You will say "exception, for sure", wouldn't you? :-)

No.  GHC possesses an out-of-memory exception that (IIRC) it never
throws, because it's simply not worth trying to recover from heap
exhaustion.  Maybe 20 years ago it was, but these days a program that
manages to exhaust space is almost certainly either buggy or poorly

An `error' is any condition where the correct response is for the
programmer to change the source code :)

> And if it is a
> result of applying
> known-to-be-very-memory-hungry algorithms to non-trivial input? Looks like
> programmer's error, doesn't it?

See above.

> And I think I can provide lots of similar examples.
> If there exists separation between errors and exceptions, it should be
> very strong
> and evident — otherwise "casual programmers" like myself will need to
> stare at the
> ceiling every time they write something to decide what suits best.

Protip: try pacing instead of staring at the ceiling.


More information about the Haskell-Cafe mailing list