I’m using: SWI-Prolog version 8.1.9
I saw this text on the docs page for freeze/2:
https://www.swi-prolog.org/pldoc/doc_for?object=freeze/2
Delay the execution of Goal until Var is bound (i.e. is not a variable or attributed variable). If Varis bound on entry freeze/2 is equivalent to call/1. The freeze/2 predicate is realised using an attributed variable associated with the module
freeze
. Usefrozen(Var, Goal)
to find out whether and which goals are delayed on Var.
For example, suppose I want to catch when a variable is first bound, could I do something like:
freeze(VarToWatch, do_something_interesting)
And do_something_interesting
might write something out, or I could set a break point on it in the graphical debugger just to use it as an execution “trap”.
Or is the freeze/2
predicate only useful in the coroutining context, which is the topic group it is a member of? I don’t really understand coroutining
yet, which is why I am asking.
If not freeze/2
, would when/2
work?