[mercury-users] Exceptions and unique modes
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Feb 21 23:37:36 AEDT 2001
On 21-Feb-2001, Peter Ross <peter.ross at miscrit.be> wrote:
>
> An interesting point was raised by Paul Massey here at MC, and that is a
> predicate should return either a status indicator or throw an exception but
> never do both.
Why not?
In cases where you expect that the immediate caller
will typically need to handle certain kinds of results (e.g. EOF), but
where you expect that other, exceptional conditions (e.g. I/O errors)
will typically need to be handled at a higher level in the
application, I think it would be quite reasonable for a predicate to
either return a status indicator or throw an exception, depending on
which conditions occur.
In many cases, especially with higher-order code or code using type
classes, it naturally arises that a procedure will return a status
indicator of some kind, but code which it can invoke via a
higher-order call or a class method call may throw an exception that
it won't know how to deal with, and must propagate to the caller.
So I don't agree.
(Of course it's never possible for a deterministic procedure to both
return a status indicator and to throw an exception *on the same call*,
but I think that's not what you meant...)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list