This library implements the when/2 constraint, delaying a goal until its arguments are sufficiently instantiated. For example, the following delayes the execution of =:=/2 until the expression is instantiated.
... when(ground(Expr), 0 =:= Expr),
nonvar(X)
ground(X)
For example (note the order a
and b
are written):
?- when(nonvar(X), writeln(a)), writeln(b), X = x. b a X = x
true
if there is no need to suspend. Nested
disjunctions are reported as or(List)
.