[m-dev.] cc_multi or det ?

Peter Schachte schachte at cs.mu.OZ.AU
Tue Aug 7 13:21:02 AEST 2001


On Mon, Aug 06, 2001 at 06:53:32PM +0200, Holger Krug wrote:
> On Mon, Aug 06, 2001 at 09:31:57AM -0700, Ralph Becket wrote:
> > The concensus was that handling
> > exceptions was as hard as handling error codes, but with a wider scope
> > for introducing bugs.
> 
> When working with exception I can concentrate on what matters, throw
> an exception when something is wrong and, in the first step, forget
> about it.

I agree with Holger.  Exceptions allow you to abstract away many of the
details about handling errors.  Since the place where an error is detected
is often not the place where a sensible decision about how to handle it can
be made, without an exception mechanism, it is often necessary to pollute
the natural types of a program with funny error codes and maybe wrappers.
This makes the main intent of the code harder to see, as it gets lost in the
clutter of error checking.  Exceptions give an out-of-band communication
mechanism that avoids the clutter.

I don't understand how exceptions give a wider scope for introducing bugs.
Is that because you forget to write handlers for them?  But you only need to
write a handler for an exception in a few places in your code, whereas you
have to write a bit of code to handle an error value all through your code.
You're more likely to forget to write part of the error handling code just
because there's so much more of it.  Sure, most of it is trivial, just
passing the error up the call chain, but the fact that it has little
semantic content, and that there is so much of it would, I expect, make it
more likely to be forgotten. And if you do forget to handle an exception,
the consequences are considerably gentler, and easier to find and correct,
than if you forget to write one error handling case.


-- 
Peter Schachte                     Humankind has narrowed its options for
mailto:schachte at cs.mu.OZ.AU        survival. The dilemma is no longer
http://www.cs.mu.oz.au/~schachte/  whether to accept violence or nonviolence
Phone: +61 3 8344 9166             but whether to accept nonviolence or
PGP key available, see web page    nonexistence. -- Mahatma Gandhi, 1948 
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list