next up previous index
Next: Profiling Prolog Execution Up: External Language Interface Previous: Nondeterministic Externals

Suspending with External Predicates

  As already mentioned earlier, external predicates can also be suspended. The macro

Mark_Suspending_Variable(var)
  is used to mark a variable which is not instantiated and therefore responsible for suspending a call. var is a pointer to the variable. If this macro is used in a normal external predicate which itself will delay, it must return to the system using the macro
Delay
 

For example, we could define a predicate atomd/1 which is like atom/1 but instead of failing it delays if its argument is not instantiated:

p_atomd(v1, t1)
value               v1;
type                t1;
{
        if (IsRef(t1))
        {
                Mark_Suspending_Variable(v1.ptr);
                Delay;
        }
        else
                Succeed_If(IsAtom(t1));
}


Micha Meier
Mon Mar 4 12:11:45 MET 1996