Hello.
I’ve encountered some strange behaviour.
I call some predicate from source by using following syntax:
:- my_predicate(parameters).
inside my_predicates uses undo/1 as part of backtrackable assertions. But they are undone immediately after predicate is finished. Using cuts didn’t help me. I assume that prolog engine undoes everything because undo/1 has nothing to do with choicepoints and cuts. It simply cleares of everything that is put in trail. Problem is that my_predicate is supposed to be used in other contexts where undoing asserts are expected, so I can’t just use non-backtrackable version of assert inside it.
Is there a way to manipulate undo records to emulate something like cut for them?
Or I just better use some global flag to supress call to undo/1?
EDIT #1: Another question arised: if undo records are not purged but cuts, does it imply that theese records might accumulate over program working even if by design program should never backtrack past undo/1 calls? Can it possibly lead to memory leaks?
EDIT #2: What is the logic of backtracking after :- or ?- calls in source code?