[mercury-users] design of stream library

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Sep 5 01:32:22 AEDT 2000


On 04-Sep-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> On Mon, Sep 04, 2000 at 09:35:26PM +1100, Michael Day wrote:
> > 
> > What guarantees should code provide regarding exceptions?
> >
> Not much in the presence of synchronous exceptions (ie those which are
> thrown in well defined places).

Code that stores global data in the io__state -- e.g. via
io__set_globals -- needs to be careful to ensure that this data
remains in a consistent state.  If such code temporarily stores
inconsistent values in the io__state, then it needs to be careful to
catch exceptions and restore some consistent value in the exception
handler.

But that kind of code is very rare in Mercury.

> Asynchronous execptions (like the user
> pressing Ctrl-C) are more problematic because you can't guarantee when
> they will be generated so you need to safeguard groups of operations
> which must be atomic.  AFAIK Mercury doesn't support asynchronous
> exceptions yet.

That is correct.

> > Are there any issues to keep in mind when designing interfaces to be
> > exception friendly?
>
> The only one I have encountered so far is that exceptions and unique
> modes don't seem to interact well.

Well, the issue there is really that exceptions and destructive update
don't interact well.  You get the same kind of problems in C++, only
the compiler won't tell you about them, instead it will quietly accept
code that leaves data structures corrupted when an exception is thrown.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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