11.3.25 (block)/1 [declaration]


:- block +BlockSpec

Specifies conditions for blocking goals of the predicates referred to by BlockSpec.


callable, must be ground

Goal template or list of goal templates, of the form f(Arg1, Arg2,...). Each Argn is one of:

part of a block condition


When a goal for a block declared predicate is to be executed, the block specs are interpreted as conditions for blocking the goal, and if at least one condition evaluates to true, the goal is blocked.

A block condition evaluates to true iff 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 true, the implementation picks one of them and blocks the goal accordingly.

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).

calls to 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.


BlockSpec not ground.
“declaration appeared in query”

See Also

Block Declarations.

Send feedback on this subject.