
demon +SpecList

   Declares the procedure(s) specified by SpecList to be demons.



Arguments
   SpecList            Comma-separated sequence of expressions of the form Atom/Integer.

Type
   Predicate Database and Compiler

Description
   The demon annotation specifies that the listed predicates are to
   be treated as demons. The only difference between a normal predicate
   and a demon is the behaviour on waking: When a normal predicate is
   delayed and gets woken, the delayed goal disappears. When a delayed
   demon gets woken, the delayed goal stays around.
   The only way to remove a demon is to explicitly kill it.




Modes and Determinism
   demon(++) is det

Modules
   This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions
     4 --- SpecList is not instantiated.
     5 --- SpecList is
	instantiated, but not to a sequence of    expressions of the form Atom/Integer.
    62 --- Predicate in SpecList already defined and is not a demon

Examples
   
     % A demon that wakes whenever X becomes more constrained
     report(X) :-
	     suspend(report(X, Susp), 1, X->constrained, Susp).

     :- demon report/2.
     report(X, _Susp) :-
	     var(X),
	     writeln(constrained(X)).  % implicitly re-suspend
     report(X, Susp) :-
	     nonvar(X),
	     writeln(instantiated(X)),
             kill_suspension(Susp).    % remove from the resolvent



     [eclipse 1]:  report(X),
             notify_constrained(X), wake,
             notify_constrained(X), wake.
     constrained(X)
     constrained(X)

     X = X

     Delayed goals:
                 report(X)
     yes.

     [eclipse 2]:  report(X),
             notify_constrained(X), wake,
             X=123.
     constrained(X)
     instantiated(123)

     X = 123
     yes.






See Also
   kill_suspension / 1, make_suspension / 3, notify_constrained / 1, schedule_suspensions / 2, set_suspension_data / 3, get_suspension_data / 3
