[Haskell-cafe] Re: New Hackage category: Error Handling

Henning Thielemann lemming at henning-thielemann.de
Mon Dec 7 19:00:54 EST 2009

On Tue, 8 Dec 2009, Ben Franksen wrote:

> Michael, Henning
> There are two meanings to the word 'exception' in this context; both of you
> tend to conflate these different meanings. One meaning is about a
> *mechanism* for non-local control flow; the other is about certain classes
> of un-desired program conditions.
> Michael, you are above arguing that it is ok to use the same /mechanism/ to
> signal errors and exceptions. That is ok with me.

I'm actually arguing that errors and exceptions (or failures) should not 
be treated the same way. This is my opinion because

1. You cannot catch all kinds of errors (infinite loops, memory 
corruption, and so on) at run-time
2. The program cannot help itself if it is buggy. The next higher level 
in the software hierarchy certainly can, but this requires obviously a 
different mechanism.

The correct treatment of those things is in my opion:

1. Errors must be fixed by the programmer
2. Exceptions must be appreciated by the programmer and handled by the program at runtime

> So, maybe it would help if we could agree to use different terms for those
> two meanings of the word 'exception'. I think 'exception' is too strongly
> associated with the non-local control flow mechanism to introduce a new
> word for it.

  I used the term "exception" because this is the term used for the concept 
of handling "file not found", "could not allocate resource" in the 
introduction to modern languages that I have read. Thus my impression was 
that "exception" is the term for the concept, whereas there are different 
implementations and ways of handling them. For instance in Modula-3 the 
EXIT statement is called an exception that escapes the LOOP structure, but 
it cannot be catched with TRY, that is used for user defined exceptions.


  In Modula-3 a detected error (range violation, NIL dereference, division 
by zero) terminates the program. An undetected error (which is restricted 
to UNSAFE modules) can cause memory corruption and all those bad things, 
and cannot be handled in any way.
  Before exceptions got a special handling in programming language, they 
still existed. In C for instance they were expressed by return codes.

  The Wikipedia author also seem to consider "exception" to be the term for 
the concept, not for the implementation:


"Exception handling is a programming language construct or computer 
hardware mechanism designed to handle the occurrence of exceptions, 
special conditions that change the normal flow of program execution."

More information about the Haskell-Cafe mailing list