next up previous
Next: 16 Backtrackable destructive assignment Up: 15 Direct binary clause Previous: 15.1 Standard Prolog catch

15.2 Ancestor cut

For enhanced control BinProlog 5.75 implements a form of ancestor cut,based on the following 3 built-ins:

get_neck_cut/1: gets the address of a choice point 
                (to be use before the first not-inlined goal)

get_deep_cut/1: gets the address of a choice point 
                (to be use after the first not-inlined goal)

cut_to/1:       cuts to a given choice-point

untrail_to/1:   removes bindings up to a given choice-point

Together with continuation manipulation and linear assumptions, the use of these built-ins allows a source-level implementation of catch and throw.

Another example of use, committing to the current resolution branch and cutting off all the alternatives up to toplevel, is written simply as:

commit :-
  assumed(catchmarker('$commit',Do,Choice,_)),
  cut_to(Choice), Do.



next up previous
Next: 16 Backtrackable destructive assignment Up: 15 Direct binary clause Previous: 15.1 Standard Prolog catch



Paul Tarau
Thu Apr 3 10:26:39 AST 1997