A nondeterminate procedure in Quintus Prolog uses a choice point , a data structure kept on an internal stack, to implement backtracking. In a simple model, a choice point is created for each call to a nondeterminate procedure, and is deleted on determinate success or failure of that call, when backtracking is no longer possible. In fact, Quintus Prolog improves upon this simple model by recognizing certain contexts in which choice points can be avoided, or are no longer needed. To avoid leaving inconsistencies between the Prolog database and outstanding calls, a retracted clause is reclaimed only when the system determines that there are no choice points on the stack that could allow backtracking to the clause. Thus, the existence of a single choice point on the stack can disable reclamation of retracted clauses for the procedure whose call created the choice point.
Space is recovered only when the choice point is deleted.
Such choice points can also disable tail recursion optimization. If not cut away, the choice point can also lead to runaway retraction on the unexpected failure of a subsequent goal. This will reduce stack size and allow the earliest possible reclamation of retracted clauses. Examples The following examples show what happens when a procedure is modified while it is running. The procedure succeeds non-determinately, and a subsequent goal makes the modification.