By using dynamic/1 one or more clauses can declared as dynamic. A dynamic clause is a
clause to which clauses can be asserted or retracted
from. The argument is a predicate indicator, a list of predicate indicators or a predicate
indicator sequence. A predicate indicator is the name of a clause followed by the operator
'/' and the arity of the clause, for instance: test / 1.
This built-in predicate can also be used as a compile directive that is executed while a
module is being compiled.
see also: abolish/1 abolish/2 asserta/1assertz/1 asserta/2 assertz/2 check_singleton/1 discontiguous/1 dynamic/2 ensure_loaded/1 import/1 import/2 import_module/1 import_module/2 include/1 initialization/1 multifile/1 predicate indicators private/0 private/1 public/0 public/1 retract/1 retract/2
| Examples | |
| dynamic( test / 0 ). | all predicates with the functor 'test' and no arguments are declared as dynamic |
| :- dynamic([legs / 2, product / 1]). legs(horse, 4). legs(human, 2). |
the predicates legs/2 and product/1 are declared as ynamic, the dynamic/1 predicate is used as a compile directive |
| test0 :- dynamic( a/1 ), assertz( a(zx) ). |
the predicate with the functor 'a' and 1 argument is declared as dynamic and the clause 'a(zx)' is asserted to the module |
| Exceptions | |
| no active module | an existence_error(active_module) exception is thrown |
| see predicate indicator for more possible exceptions | |