[mercury-users] inferred determinism
Thomas Conway
conway at cs.mu.OZ.AU
Tue Feb 26 20:46:33 AEDT 2002
On Tue, Feb 26, 2002 at 04:56:43PM EST, Fergus Henderson wrote:
> On 26-Feb-2002, Michael Day <mikeday at bigpond.net.au> wrote:
> >
> > The compiler infers a determinism of nondet for the predicate foo below,
> > unless the call to `zero' in the first clause is replaced by the literal
> > value 0. But it's an output argument, so why should it care?
> >
> > :- pred foo(int, list(T)).
> > :- mode foo(out, in) is det.
> >
> > foo(zero, []).
> > foo(N, [_|Xs]) :- foo(N0, Xs), N = N0+1.
> >
> > :- func zero = int.
> > zero = 0.
>
> Switch detection will not look past function calls.
> It only looks for unifications that occur before the
> first function call or predicate call in the clause.
> (One reason for this is that moving unifications across function
> calls could change whether or not the program terminates;
> e.g. consider the case where `zero' loops.)
This argument only applies in the case of the strict sequential model.
I had a diff somewhere once that fixed this. Sometimes it can be jolly
inconvenient to move all the function calls out of the way.
T.
--
Thomas Conway )O+
<conway at cs.mu.oz.au> 499 User error! Replace user, and press any key.
--------------------------------------------------------------------------
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