 
 
 
A predicate may have one or more delay clauses. They have to be textually before and consecutive with the normal clauses of the predicate they belong to. The simplest example for a delay clause is one that checks if a variable is instantiated:delay <Head> if <Body>.
delay report_binding(X) if var(X).
report_binding(X) :-
        printf("Variable has been bound to %w\n", [X]).
does not match the goal p(A, b) but it matches the goal p(a, b).delay p(a, X) if var(X).
delay integer_list(L) if var(L). delay integer_list([X|_]) if var(X). integer_list([]). integer_list([X|T]) :- integer(X), integer_list(T).
delay p(X, X, Y) if var(Y).
delay p(X) if compound(X), arg(1, X, Y), nonground(Y).
delay p(X) if nonground(2, X).
executed with the call ?- p(a, b) of course succeeds and the call delays forever, since no variable binding can wake it.delay p(X, Y) if X \== Y.
 
 
