[mercury-users] exceptions considered bloody annoying

Michael Day mikeday at bigpond.net.au
Tue Apr 16 15:08:22 AEST 2002

> Database people insist upon transactional integrity and have the
> appropriate machinery (logging, optimistic concurrency etc.) to support
> that goal.

Logic programming languages already have transactional integrity in the
absence of destructive update. I can write semidet predicates that
manipulate lists and they can backtrack on failure and preserve the
original input and everything is fine, but when I want to manipulate io
states to send bytes through the network it's hard for the language to
undo that operation for me automatically when I change my mind.

As soon as you start destructively updating unique structures you're back
in C++ land and you can't abandon a line of computation without losing
your data. But exceptions give you the idea that you can, that you can
just throw one and it's like backtracking and everything will be alright.

Here is a proposal: remove try and try_io from the library. If you want to
run dynamically loaded code without putting yourself at risk of errors,
then fork a child process to dynamically load and execute the code. It can
throw an exception, die, and the operating system will close its files and
release its memory. Then we can go back to using error for determinism
assertions and exceptions will stop screwing up interfaces.

(Or insert alternative suggestions for maintaining transactional integrity
while destructively updating data structures).


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