Next: mpg-ref-retractall, Previous: mpg-ref-restore, Up: mpg-bpr [Contents][Index]
retract/1
ISOretract(+Clause)
Removes the first occurrence of dynamic clause Clause from module M.
callable, must be nonvar
A valid Prolog clause.
retract/1
erases the first clause in the database that matches
Clause. Clause is retracted in module M if
specified. Otherwise, Clause is retracted in the source module.
retract/1
is nondeterminate.
If control backtracks into
the call to retract/1
, then successive clauses matching Clause are
erased. If and when no clauses match, then the call to retract/1
fails.
If the predicate did not previously exist, then
it is created as a dynamic predicate and retract/1
fails.
Clause must be of one of the forms:
Head :- Body
Module:Clause
where Head is of type callable and the principal functor of Head is the name of a dynamic procedure. If specified, then Module must be an atom.
retract(Head)
means retract the unit-clause Head. The exact
same effect can be achieved by retract((Head :- true))
.
Body may be uninstantiated, in which case it will match any body. In
the case of a unit-clause it will be bound to true
. Thus, for
example,
| ?- retract((foo(X) :- Body)), fail.
is guaranteed to retract all the clauses for foo/1
, including any
unit-clauses, providing of course that foo/1
is dynamic.
Can be used to retract all matching clauses through backtracking.
instantiation_error
Head (in Clause) or M is uninstantiated.
type_error
Head is not a callable, or M is not an atom, or Body is not a valid clause body.
permission_error
the procedure corresponding to Head is not dynamic
retractall/1
, ref-mdb-rcd.