[mercury-users] Exceptions and unique modes

Peter Ross peter.ross at miscrit.be
Wed Feb 21 23:00:34 AEDT 2001


On Thu, Feb 15, 2001 at 07:53:25AM -0800, Ralph Becket wrote:
> >From Fergus Henderson on 15/02/2001 15:42:09
> > 
> > A better alternative, IMHO, is to ensure that no exceptions will be
> > raised during those points, i.e. ensure that all updates to the
> > io__state are atomic.  For store__set_mutvar and io__set_globals, this
> > will come for free on most implementations, I think, since the crucial
> > steps are just pointer assignments.
> 
> What happens when we store another unique object in a mutvar in the 
> io__state (*), get it and perform some operation that raises an
> exception before we've put it back?  The mutvar now no longer holds a
> valid reference to our unique object, but the exception handler can't
> know that.  In fact, it's impossible to work out whether the inst for
> the io__state as delivered to the exception handler is "unique, containing
> mutvar reference to dead value" or "unique, containing mutvar reference to
> unique value."
> 
This is why I am thinking that you need to use one name for the unique
object and guarantee that in the presence of exceptions, this name will
represent the last handle on the unique type.  I am hopeful that we
can represent this as some sort of source-to-source transformation.

Of course one problem with this is code-reuse.  Code written which
threads a state variable (in, out) will no be able to be simply
converted to (di, uo).

Pete

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