[mercury-users] Loop Checking

Richard Hagen richard at it.uq.edu.au
Fri Oct 29 10:29:23 AEST 1999


In message <19991029010341.A1935 at murlibobo.cs.mu.OZ.AU>, Fergus Henderson write
s:
>On 28-Oct-1999, Richard Hagen <richard at it.uq.edu.au> wrote:
>I suspect that there is a good chance that `pragma loop_check' does
>not do exactly what you want.  But have a look at the documentation
>and/or try it out and let us know whether it satisfies your requirements.

The goal has got extra baggage (alas) that makes pragma loop_check
inapplicable. An goal of the form g(X) is compiled
into a form like 
	compiled_g(X, PositiveAncestores, NegativeAncestors, ...)
In a Prolog system, you'd do the loop check by a variation on member/2
that uses (==) rather than unification as its test of equality. e.g.
	identical_member(g(X), PositiveAncestors) -> !, fail
When calling sub goals, the current goal is prepended to the list of
ancestors e.g.
	compile_g_sub(X, [ g(X) | PositiveAncestors ], NegativeAncestors, ...)
which is why the pragma loop_check isn't quite what I want. (The ancestor
arguments are used in other ways in the code, so I can't really get by
without them.)

Now, it might be nice if there was some way to say
	:- pragma loop_check(Name/Arity, ArgumentList).
However, I'd be worried about the runtime error
mentioned in the pragma loop_check documentation. Would it be reasonable
and safe to replace this with an exception (or, better, failure)?

Thanks for the speedy and helpful reply!

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