Node:Placement of Cuts, Next:Terminating a Backtracking Loop, Previous:Making Predicates Determinate, Up:The Cut
Programs can often be made more readable by the placing of cuts as early as
possible in clauses. For example, consider the predicate p/0
defined by
p :- a, b, !, c, d. p :- e, f.
Suppose that b/0
is a test that determines which clause of
p/0
applies; a/0
may or may not be a test, but c/0
and d/0
are not supposed to fail under any circumstances. A cut
is most appropriately placed after the call to b/0
. If in fact
a/0
is the test and b/0
is not supposed to fail, then it
would be much clearer to move the cut before the call to b/0
.
A tool to aid in determinacy checking is included in the distribution. It is described in depth in The Determinacy Checker.