[m-dev.] for review: MLDS back-end: library fixes

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Dec 8 14:37:57 AEDT 1999


On 08-Dec-1999, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> I think that's a good idea, providing:
...
>   2)  there's some mechanims for saying "yes I know I could have
>       declared this predicate to be det, but I prefer to make it
>       semidet for some reason" which would shut up the warning.
>       maybe something like
> 
> 	:- pred blah(blah, blah) is declared semidet.

Something along these lines would be a good idea, IMHO.

Making it part of the `pred' or `mode' declaration is probably not
appropriate, though, because the fact that the declared determinism is
not the same as the determinism that the compiler infers (from the
procedure's implementation) is an implementation detail, not part of the
procedure's interface.

We do have predicates `semidet_succeed', `semidet_fail', and `cc_multi_equal'
in the standard library, which can be used to supress these warnings.
In most cases it is fairly easy:

	- where the procedure was declared `semidet' but inferred `det',
	  or was declared `cc_nondet' but inferred `cc_multi',
	  insert a call to `semidet_succeed'

	- where the procedure was declared `cc_multi' but inferred `det',
	  or was declared `cc_nondet' but inferred `semidet',
	  insert a call to `cc_multi_equal' for one of the output variables

	- where the procedure was declared `cc_nondet' but inferred `semidet',
	  combine the two previous solutions, i.e. use both `cc_multi_equal'
	  and `semidet_succeed'

There probably ought to be a `multi_equal' procedure too, for handle the
corresponding non-cc cases.

In cases where the compiler infers determinism
`failure' or `erroneous' it is a bit more difficult,
but still possible:

	- where the procedure was declared `det' but inferred `erroneous',
	  or was declared `semidet' but inferred `failure', wrap the body
	  of the procedure inside `(semidet_fail -> semidet_succeed ; <Body>)'.

	- where the procedure was declared something else but
	  inferred `erroneous' or `failure', combine the solutions
	  described above, i.e. wrap the body as above and also
	  insert a call to semidet_succeed and/or cc_multi_equal
	  in the body.

A more severe problem is that this approach doesn't work in the case of
multi-moded predicates.  Allowing different code for different modes
would lessen that problem, but even so, it would be nice to have
a nicer syntax for supressing these warnings, in particular one that
didn't require modifying the procedure's code.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list