Two alternatives come to mind:
- Pass the code
backtrack(true) or backtrack(false) through the code you want to control and interpret it in the definition of the predicates that you write to quickly execute if it is set to backtrack(false) , or continue if backtrack(true) . Note that this does not actually prevent rollback; it should just enable a quick glitch. Even if your evidence tree is deep, this should provide a quick way to prevent certain code from executing with backtracking. - Use exceptions as pointed out by @Xonix (+1). Throwing exceptions will immediately stop creating the evidence tree, and you can pass any term data except to the handler, bypassing any execution - it will probably be faster than the first option, but may not be as portable.
Personally, I used both methods before - the first where I expected the need before writing code, and the second where I do not.
source share