:- block :BlockSpec, …, :BlockSpec.
where each BlockSpec is a skeletal goal, specifies conditions
for blocking goals of the predicate referred to by the
skeletal goal (
The arguments of the skeletal goal can be:
When a goal for
to be executed, the mode specs are interpreted as conditions for
blocking the goal, and if at least one condition evaluates
true, the goal is blocked.
A block condition evaluates to
true if and only if all arguments
specified as ‘-’ are uninstantiated, in which case the
goal is blocked until at least one of those variables
is instantiated. If several conditions evaluate to
the implementation picks one of them and blocks the goal
The recommended style is to write the block declarations in front of the source code of the predicate they refer to. Indeed, they are part of the source code of the predicate, and must precede the first clause. For example, with the definition:
:- block merge(-,?,-), merge(?,-,-). merge(, Y, Y). merge(X, , X). merge([H|X], [E|Y], [H|Z]) :- H @< E, merge(X, [E|Y], Z). merge([H|X], [E|Y], [E|Z]) :- H @>= E, merge([H|X], Y, Z).
merge/3 having uninstantiated arguments in
the first and third position or in the second and
third position will suspend.
The behavior of blocking goals for a given predicate on uninstantiated arguments cannot be switched off, except by abolishing or redefining the predicate. See mpg-ref-block.