[m-dev.] cc_multi or det ?

Ralph Becket rbeck at microsoft.com
Tue Aug 7 18:59:16 AEST 2001


> From: Peter Schachte [mailto:schachte at cs.mu.OZ.AU]
> Sent: 07 August 2001 04:21
> 
> 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 use error codes in places where I expect to have to recover from 
errors and exceptions for more drastic situations where graceful 
recovery is largely not an option.

Handling errors of the former kind with exceptions often makes my
code less legible than the equivalent kind using error codes.

> I don't understand how exceptions give a wider scope for introducing
bugs.
> Is that because you forget to write handlers for them?

That's largely it.  If I don't *have* to write error handling code on
the first pass, I probably won't.  Mercury style error codes don't give
me this option: I have to deal with them when they arise.

The other problem is that retrofitting error recovery code can be a
major pain, particularly if there's some state you want to preserve
from the point at which the error occurred.

The Haskell and ML programmers I know are great fans of the monadic
style for just this reason.

- Ralph
--------------------------------------------------------------------------
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