Section "database"
Besides input/output, the dynamic database of a Prolog system
provides further means to have side effects by Prolog code.
Currently we do compile the surface of Prolog dynamic clauses to
correctly handle the cut. Since this is still done in 100% Prolog
it incures a little extra cost in storage and retrieval, when the
clause has a body.
Otherwise clause store and retrieval is now mostly native code,
which makes the dynamic database quite speedy for facts. The
recent releases have also seen just-in-time indexing and assertion
sharing, besides the program sharing that was already present in
initial versions of Dogelog Player. The latest addition are
pre-computed hash indexes.
The following database predicates are provided:
- dynamic(I): [ISO 7.4.2.1]
- The predicate succeeds. As a side effect, it touches the
predicate I and ensures that it is dynamic.
- prehash(I):
- The predicate succeeds. As a side effect, it touches the
predicate I and ensures that it is uses a pre-computed hash
index.
- asserta(C): [ISO 8.9.1]
- The predicate succeeds. As a side effect, the clause C is
inserted at the top.
- assertz(C): [ISO 8.9.2]
- The predicate succeeds. As a side effect, the clause C is
inserted at the bottom.
- clause(H, B): [ISO 8.8.1]
- The predicate succeeds with the clauses that unify H :- B.
- retract(C): [ISO 8.9.3]
- The predicate succeeds with the clauses that unify C. As a
side effect, the clause is removed.
- retractall(H): [TC2 8.9.5]
- The predicate succeeds. As a side effect, the clauses that
unify the head H are removed.
- abolish(I): [ISO 8.9.4]
- The predicate succeeds. As a side effect, the predicate I is
destroyed.
- current_predicate(I): [ISO 8.8.2]
- The predicate succeeds in I with current predicate indicators.
- predicate_property(I, P):
- The predicate succeeds in P with the properties of the
predicate indicator I. The following properties are supported:
- static: The predicate is static.
- dynamic: The predicate is dynamic.
- built_in: The predicate is built-in.
- sys_multifile(S): The predicate is marked multifile in the
source path S.
- sys_usage(S): The predicate is defined in the source path S.
- sys_discontiguous(S): The predicate is marked discontinuous in
the source path S.