Hi,
I do not understand the behaviour of the following program related to the interaction bewteen backtracking and the message_hook/3 predicate.
message_hook(_, informational, _).
message_hook(frame(_:Atom,trace(exit,_)), debug, _ ) :-
writeln(message_hook(frame(_:Atom,trace(exit,_)), debug, _ )).
p(a).
p(b).
p(c).
Now with SWI 64bits, v9.2.5, I get:
2 ?- p(X).
X = a ;
X = b ;
X = c.
3 ?- trace(p/1,+exit), p(X), trace(p/1,-exit).
message_hook(frame(_5174:p(a),trace(exit,_5182)),debug,_5164)
X = a ;
message_hook(frame(_7180:p(b),trace(exit,_7188)),debug,_7170)
message_hook(frame(_7534:p(c),trace(exit,_7542)),debug,_7524)
false.
I understand that before displaying X = a
, trace(p/1,-exit)
has been successfully executed. But, when backtracking on p(X)
, why does it still launch message_hook/3 and doesn’t he display X = b
and X = c
?
Thanks in advance