[mercury-users] Determinism question

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Sep 7 00:52:56 AEST 2001


On 06-Sep-2001, Nicholas James Nethercote <njn at cs.mu.OZ.AU> wrote:
> I'm wondering about what happens when you have a conjunction of the form
> (semidet, erroneous)... the compiler infers such a conjunction as `failure'.

Correct.

> The Mercury Reference Manual says this about `failure' and `erroneous':
> 
>     If all possible calls to a particular mode of a predicate or function fail
>     without producing a solution, then that mode has a determinism of failure. 
> 
>     If all possible calls to a particular mode of a predicate or function lead
>     to a runtime error, i.e. neither succeed nor fail, then that mode has a
>     determinism of erroneous.
> 
> But then it has this summary diagram:
> 
>                     Maximum number of solutions
>     Can fail?       0               1               > 1
>     no              erroneous       det             multi
>     yes             failure         semidet         nondet
> 
> The information is subtly different - if we are working from the table, the
> procedure is clearly `failure';  if we are working from the sentences, the case
> isn't really covered.  
> 
> So are the sentences just imprecisely worded, or is there some deeper
> explanation?

The former.
The sentences are correct but not a complete description of all the
possibilities.  The table is correct and complete.

> And another thing - if interesting_case/1 above is inferred as failure, is
> there a possibility that a call to it might be optimised away and replace with
> `fail'?  Because that would change the behaviour of the above program.  Or does
> the compiler check whether a `failure' procedure might throw an error before it
> optimises it away like that?

The compiler will perform such optimizations only if the --no-fully-strict
option is enabled, which is not the default.  See the user's guide for a
description of that option.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  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