[m-dev.] cc_multi or det ?
Peter Schachte
schachte at cs.mu.OZ.AU
Wed Aug 8 13:48:25 AEST 2001
On Tue, Aug 07, 2001 at 01:59:16AM -0700, Ralph Becket wrote:
> 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.
Can you give a simple example? I find polluting the datatypes with error
wrappers, and the code with wrapping and unwrapping, makes code less legible.
> If I don't *have* to write error handling code on
> the first pass, I probably won't.
That's a *good* thing: it lets you concentrate on the main concepts, and
deal with the fiddly error cases later. I suppose you'll argue that that's
a bad thing because you might design yourself into a corner, and not be able
to get a sensible design when you need to code for the error cases. I
haven't seen this; I guess that's what I'd like an example of.
> Mercury style error codes don't give
> me this option: I have to deal with them when they arise.
Only if all your code is det.
> 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.
Can't you just pass that state back in the exception term?
--
Peter Schachte In a democratic time culture, everyone's
mailto:schachte at cs.mu.OZ.AU time is valueable and no one's time is
http://www.cs.mu.oz.au/~schachte/ any more expendable than another's.
Phone: +61 3 8344 9166 -- Jeremy Rifkin
PGP key available, see web page
--------------------------------------------------------------------------
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