[mercury-users] io output exceptions
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Nov 14 19:02:38 AEDT 2002
On 14-Nov-2002, Michael Day <mikeday at yeslogic.com> wrote:
>
> > (1) I/O errors are rare
> > (2) Throwing an exception is usually the right action.
>
> In that case, why don't input operations throw exceptions?
>
> Ralph says:
>
> "One expects a result from an input and has to be prepared for at least
> success and eof, so also handling error cases that way seems natural."
>
> but it does complicate parsing code as you end up with three branches
> after every operation instead of two.
True, but it's only a minor complication.
Operations that open files don't throw exceptions on I/O errors because
errors when opening files are common, not exceptional. I don't think
those should change. For operations which read data from an already-opened
file, we might change the interface in version 2 of the library.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | 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