gated_call/4

gated_call(0:Setup, 0:Goal, ?Port, 0:Handler)*

This predicate watches over execution of Goal:

  • First, it calls once(Setup);

  • Next, it executes call(Goal);

  • if call(Goal) succeeds deterministically, it unifies Port with exit and if unification succeeds calls Handler;

  • if call(Goal) succeeds not-deterministically, it unifies Port with answer and if unification succeeds calls Handler;

  • if execution backtracks to Goal, it unifies Port with redo and if unification succeeds calls Handler;

  • if execution of Goal fails, it unifies Port with fail and if unification succeeds calls Handler;

  • if execution of Goal is pruned by an external goal, it unifies Port with ! and if unification succeeds calls Handler;

  • if execution of Goal raises an exception E, it unifies Port with exception(E) and if unification succeeds calls Handler;

  • if Goal has open alternatives that are discared by an exception E, it unifies Port with external_exception(E) and if unification succeeds calls Handler.