chickadee » amb » amb-failure-continuation

amb-failure-continuationprocedure
amb-failure-continuation STATUS-VARIABLEprocedure

Seen in a global context, the amb operator transforms the whole program that contains it into a depth first search for return values from amb forms that will not cause failure.

This is realized using a backtracking system that invokes previously stored continuations whenever an amb expression fails. The amb-failure-continuation parameter is the status variable for this system.

At the start of the program, or when no further backtracking options are available, this is set to a procedure of no arguments that raises an exception condition (exn amb) (except when a amb-collect statement is being processed, where the parameter will point to a procedure signalling amb-collect that there are no more backtracking options available).

In all other cases this parameter is set to a procedure of no arguments that causes backtracking to the next possible alternative in the tree.

If you want to restrict the scope of backtracking to something smaller than the whole past program, use amb-find or amb-collect which restore this parameter to its original value when they are done evaluating the expressions they were given.