Next: , Previous: ref-mdb-exa, Up: ref-mdb


4.12.8 The Internal Database

The following predicates are provided solely for compatibility with other Prolog systems. Their semantics can be understood by imagining that they are defined by the following clauses:

     recorda(Key, Term, Ref) :-
          functor(Key, Name, Arity),
          functor(F, Name, Arity),
          asserta('$recorded'(F,Term), Ref).
     recordz(Key, Term, Ref) :-
          functor(Key, Name, Arity),
          functor(F, Name, Arity),
          assertz('$recorded'(F,Term), Ref).
     recorded(Key, Term, Ref) :-
          functor(Key, Name, Arity),
          functor(F, Name, Arity),
          clause('$recorded'(F,Term), _, Ref).

The reason for the calls to functor/3 in the above definition is that only the principal functor of the key is significant. If Key is a compound term, its arguments are ignored.

Please note: Equivalent functionality and performance, with reduced memory costs, can usually be had through normal dynamic procedures and indexing (see ref-mdb-bas and Indexing).

recorda(Key, Term, Ref) records the Term in the internal database as the first item for the key Key; a database reference to the newly-recorded term is returned in Ref.

recordz(Key, Term, Ref) is like recorda/3 except that it records the term as the last item in the internal database.

recorded(Key, Term, Ref) searches the internal database for a term recorded under the key Key that unifies with Term, and whose database reference unifies with Ref.

current_key(KeyName, KeyTerm) succeeds when KeyName is the atom or integer that is the name of KeyTerm. KeyTerm is an integer, atom, or compound term that is the key for a currently recorded term.


Send feedback on this subject.