[mercury-users] Exceptions and unique modes

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 16 02:01:22 AEDT 2001


On 15-Feb-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> On Thu, Feb 15, 2001 at 03:52:30PM +1100, Fergus Henderson wrote:
> > > >From Peter Ross on 14/02/2001 16:23:43
> > > > 
> > > > Currently the only unique object which can be used with exceptions is an
> > > > io__state, and it makes the assumption that the io__state you get back
> > > > when an exception is thrown is the one that existed at the time of the
> > > > exception.
> > 
> > No, it doesn't.  The io__state that you get back when an exception is
> > thrown will in general be different from the one that existed at the
> > time the exception was thrown.  If any I/O has been done when the
> > exception has been thrown, then the state that you get back will
> > include all the side effects of whatever I/O has been done.
> 
> What I was trying to say is that the io__state you get back when you
> catch the following exception is IO1.
> 
>     do_some_io(IO0, IO1),
>     throw(exception)

Not necessarily.  The compiler could well optimize that code to just

	throw(exception)

But *if* it doesn't optimize away the call to do_some_io, or do any
other such optimizations, then yes, the io__state that you get back
will be IO1.

> I am really starting to think that threaded unique objects, should be
> treated specially in the language, maybe with some sort of special
> syntax which allowed you to use one name to talk about a threaded unique
> object and the compiler was smart enough to do a source-to-source
> transformation which made this all declarative.

Well, if using one name to talk about a threaded unique object is what
you want, I think you may perhaps be able to do it using mutvars
(see library/store.m).

It would be nice if we were to provide something similar to that
but which works on the io__state rather than a separate store type.
We could improve do that by providing procedures io__new_mutvar,
io__set_mutvar, and io__get_mutvar to parallel the versions in store.m.
(Currently the only way to keep the store in the io__state is via
io__set_globals/io__get_globals, which is a bit of a hack, and not
maximally convenient.)

We could also use the new record syntax for mutvars.

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