wait/1¶
support for when//22 like declaration.
use a meta interpreter for now% make sure we have module info for G!% now for the important bit% Support for wait declarations on goals.% Or we also use the more powerful, SICStus like, "block" declarations.%% block or wait declarations must precede the first clause.% I am using the simplest solution now: I'll add an extra clause at% the beginning of the procedure to do this work. This creates a% choicepoint and make things a bit slower, but it's probably not as% significant as the remaining overheads.% find out what we are blocking on.% If we suspend on the conditions, we should continue% execution. If we don't suspend we should fail so that we can take% the next clause. To% know what we have to do we just test how many variables we suspended% on ;-).% We generate code as follows:%% block a(-,-,?)%% (var(A1), var(A2) -> true ; fail), !, when((nonvar(A1);nonvar(A2)),G).%% block a(-,-,?), a(?,-, -)%% (var(A1), var(A2) -> true ; (var(A2), var(A3) -> true ; fail)), !,% when(((nonvar(A1);nonvar(A2)),(nonvar(A2);nonvar(A3))),G).
wait(G)* The argument to wait//11
is a predicate descriptor or a conjunction of these predicates. These predicates will suspend until their first argument is bound.
The wait declaration is a simpler and more efficient version of block.