[ Dynamic Predicates | Reference Manual | Alphabetic Index ]

retractall(+Head)

Removes from the database all clauses whose heads match Head
Head
Atom, variable or compound term.

Description

Retracts from the database all clauses whose heads match the argument. The argument must be sufficiently instantiated otherwise an error is signalled. retractall/1 never fails. The clauses are not reasserted when backtracking through the call of retractall/1.

The functor and the arity of Head must be that of a predicate declared as dynamic (or implicitly declared as dynamic by asserting).

retractall/1 satisfies the logical update semantics. Using it to retract all the clauses of a predicate will not, in any way, affect previous calls to the predicate, i.e. they will still see all the clauses that existed at call time.

Modes and Determinism

Modules

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

Exceptions

(4) instantiation fault
Head is not instantiated
(5) type error
Head is not a callable term
(63) procedure not dynamic
Procedure is not dynamic
(70) accessing an undefined dynamic procedure
Procedure is undefined

Examples

Success:
    [eclipse]: assert(city(munich)), assert(city(london)).
    yes.
    [eclipse]: retractall(city(_)).
    yes.
    [eclipse]: city(X).
    no (more) solution.
    [eclipse]: retractall(city(_)).
    yes.
Error:
    retractall(X).                  (Error 4).
    retractall("x").                (Error 5).


   % if h/0 is defined, but not as dynamic..
    retractall(h).                  (Error 63).

    retractall(z/0).                (Error 70).



See Also

dynamic / 1, assert / 1, retract / 1