Logtalk reference manual
Predicate directive: dynamic/1
Contents > Reference Manual > Directives > dynamic/1

## dynamic/1

#### Description

    dynamic(Functor/Arity)
    dynamic((Functor1/Arity1, ...))
    dynamic([Functor1/Arity1, ...])

    dynamic(Entity::Functor/Arity)
    dynamic((Entity1::Functor1/Arity1, ...))
    dynamic([Entity1::Functor1/Arity1, ...])

    dynamic(Module:Functor/Arity)
    dynamic((Module1:Functor1/Arity1, ...))
    dynamic([Module1:Functor1/Arity1, ...])

    dynamic(Functor//Arity)
    dynamic((Functor1//Arity1, ...))
    dynamic([Functor1//Arity1, ...])

    dynamic(Entity::Functor//Arity)
    dynamic((Entity1::Functor1//Arity1, ...))
    dynamic([Entity1::Functor1//Arity1, ...])

    dynamic(Module:Functor//Arity)
    dynamic((Module1:Functor1//Arity1, ...))
    dynamic([Module1:Functor1//Arity1, ...])

Declares dynamic predicates and dynamic grammar rule non-terminals. Note that an object can be static and have both static and dynamic predicates/non-terminals. Dynamic predicates cannot be declared as synchronized. When the dynamic predicates are local to an object, declaring them also as private predicates allows the Logtalk compiler to generate optimized code for asserting and retracting predicate clauses. Categories can also contain dynamic predicate directives but cannot contain clauses for dynamic predicates.

The predicate indicators (non-terminal indicators) can be explicitly qualified with an object identifier or a category identifier when the predicates (non-terminals) are also declared multifile.

Note that dynamic predicates cannot be declared synchronized (when necessary, declare the predicates updating the dynamic predicates as synchronized).

#### Template and modes

    dynamic(+predicate_indicator_term)
    dynamic(+non_terminal_indicator_term)

    dynamic(+object_identifier::+predicate_indicator_term)
    dynamic(+object_identifier::+non_terminal_indicator_term)

    dynamic(+category_identifier::+predicate_indicator_term)
    dynamic(+category_identifier::+non_terminal_indicator_term)

    dynamic(+module_identifier:+predicate_indicator_term)
    dynamic(+module_identifier:+non_terminal_indicator_term)

#### Examples

    :- dynamic(counter/1).

    :- dynamic((lives/2, works/2)).

    :- dynamic([db/4, key/2, file/3]).

#### See also

`dynamic/0`