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

Peter Schachte schachte at cs.mu.OZ.AU
Wed Dec 8 17:23:21 AEDT 1999


On Wed, Dec 08, 1999 at 02:37:57PM +1100, Fergus Henderson wrote:
> > 	:- 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

Oh, yeah, sorry, I meant :- mode ....

> 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.

Fair enough.  It doesn't belong in the 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.

It really doesn't seem appropriate to me to contort your code and lie
to the compiler just to avoid some warnings.

> 	- 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>)'.

This, IMHO, is making a pretzel of your code.  I think it would be
better to keep this out of the code, and to tell the truth.  Also, it
should be possible to make such a declaration for each mode of a
predicate, and that leads to the sort of declaration I proposed above.
Basically, you have to repeat the mode declaration to specify which
mode of which predicate has an inferred mode that differs from its
declared mode.

Perhaps the best solution is to use the declaration I proposed above,
but have it appear in the interface without the `declared' keyword,
and repeated in the interface with `declared'.  Of course, if the
predicate is private, it only need be written once.

Another way, simpler but a bit more heavy-handed, would be to simply
add a pragma something like

	  :- pragma imprecise_declared_determinism foo/4.

which would turn off warnings for declared determinisms of all modes
of the specified predicate being too weak.  This would be a little
disappointing, since if you've had to play with the declared
determinism of one mode of a predicate, it's not unlikely that the
determinism of some other modes might be a bit odd, too.


-- 
Peter Schachte                     Lisa, if you don't like your job you
mailto:schachte at cs.mu.OZ.AU        don't strike. You just go in every day
http://www.cs.mu.oz.au/~schachte/  and do it really half-assed. That's the
PGP: finger schachte at 128.250.37.3  American way. -- Homer Simpson 
--------------------------------------------------------------------------
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