[mercury-users] Exceptions, determinism and purity

Nicholas Nethercote njn at csse.unimelb.edu.au
Fri Mar 7 13:48:34 AEDT 2008


Hi,

Take this predicate:

   :- pred p(int::in) is det.

It is det and doesn't produce any output.  So at first glance you'd think 
you could safely remove any call to it.

But, it could be defined like this:

   pos(X) :- ( if X >= 0 then true else error("negative!") ).

So removing calls could clearly change a program's behaviour.

So it seems that exceptions/aborting falls outside of the determinism 
system.  Well, I realise that 'erroneous' is interpreted as "guaranteed to 
have a solution;  has at most 0 solutions", but I'm struggling to see how 
that theoretical viewpoint and the practical reality (eg. "can I remove this 
call?") meet.

Is the answer just "you can't remove any call to any predicate"?  Then it's 
more like 'pos' has some kind of impurity.

Does the Mercury manual address this?

Nick
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list