dynamic(+atom_module, +predicate_indicator)

With this built-in predicate dynamic/2 one or more clauses in a specific module can declared as dynamic, this module may be any module. A dynamic clause is a clause to which clauses can be asserted or retracted from. The second 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 cannot be used as a compile directive like dynamic/1 and dynamic/2 is not defined in the ISO Prolog standard/

see also: abolish/1 abolish/2 asserta/1 assertz/1 asserta/2 assertz/2 check_singleton/1 discontiguous/1 dynamic/1 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( program, test / 0 ). all predicates with the functor 'test' and no arguments are declared as dynamic in the module 'program'
:- dynamic(data, [legs / 2, insect / 2]).
legs(horse, 4).
legs(human, 2).
fails because dynamic/2 cannot be used as a compile directive.
test0 :-
  dynamic( data, a/1 ),
  assertz( data, a(zx) ).
the predicate with the functor 'a' and 1 argument is declared as dynamic in the module named 'data' and the clause 'a(zx)' is asserted to that same module

 

Exceptions
module name is not a valid atom an type_error(atom, Arg) exception is thrown, Arg is replaced by the incorrect module name
no module with the specified module name an existence_error(module, ModuleName) exception is thrown
see predicate indicator for more possible exceptions

 

 

info@trinc-prolog.com