[mercury-users] inferred determinism
Mark Brown
dougl at cs.mu.OZ.AU
Wed Feb 27 01:14:06 AEDT 2002
On 26-Feb-2002, Michael Day <mikeday at bigpond.net.au> wrote:
>
> > 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.)
>
> That's unfortunate, as it seems very much an implementation dependent
> limitation in determinism analysis (regardless of how impractical it would
> be to handle correctly)
The limitation is documented in the reference manual (in the section
'Determinism checking and inference'), which means that it is not
implementation dependent. All implementations of Mercury are expected
to use the same rules to determine whether or not a disjunct is a switch.
and the error message is very unobvious if you
> don't know how determinism analysis works as it refers to the list
> argument rather than the function argument. (As usual, permute the code
> until it compiles...)
I agree that the programmer needs to understand the rules of switch
detection, in order to understand determinism errors like this one.
Indeed, the programmer should be mentally applying these rules as they
write their code, if they want to avoid the trial and error approach
to compilation. This is another reason for restricting the places that
the switch unifications can appear -- to limit the amount of code that
the programmer has to search through in order to find them.
Cheers,
Mark.
--------------------------------------------------------------------------
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