assertz/1¶
Description¶
assertz(Head)
assertz((Head:-Body))
Asserts a clause as the last one for a dynamic predicate. If the
predicate is not previously declared (using a scope directive), then a
dynamic predicate declaration is added to the object (assuming that we
are asserting locally or that the
dynamic_declarations compiler flag
was set to allow
when the object was created or compiled).
When the predicate indicator for Head
is declared in a uses/2 or
use_module/2 directive, the clause is asserted in the referenced
object or module.
This method may be used to assert clauses for predicates that are not declared dynamic for dynamic objects provided that the predicates are declared in this. This allows easy initialization of dynamically created objects when writing constructors.
Modes and number of proofs¶
assertz(+clause) - one
Errors¶
instantiation_error
type_error(callable, Head)
type_error(callable, Body)
permission_error(modify, private_predicate, Name/Arity)
permission_error(modify, protected_predicate, Name/Arity)
permission_error(modify, static_predicate, Name/Arity)
permission_error(create, predicate_declaration, Name/Arity)
Examples¶
assertz(Clause)
::assertz(Clause)
Object::assertz(Clause)
See also
abolish/1, asserta/1, clause/2, retract/1, retractall/1 dynamic/0, dynamic/1, uses/2, use_module/2