[mercury-users] io output exceptions

Ralph Becket rafe at cs.mu.OZ.AU
Thu Nov 14 17:20:23 AEDT 2002


Michael Day, Thursday, 14 November 2002:
> 
> In that case, why don't input operations throw exceptions?

We may well revisit this decision for version 2 of the library.

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

You can always put your own wrapper around the IO operations that
only has two possible outcomes (bar an exception).

Of course, if the files you're working with are small enough (i.e. these
days they can be quite substantial), you may be able to just read the
whole thing in as a string and work with that.

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