Next: , Previous: , Up: The Cut   [Contents][Index]

9.4.3 Placement of Cuts

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.

Send feedback on this subject.