[ Recorded Database | Reference Manual | Alphabetic Index ]

rerecord(+Key, ?Value)

Erases all entries recorded under key Key and replaces them with the given value Value.
Key
An atom or a compound term.
Value
An arbitrary term.

Description

Used to erase all values associated with Key and then record the term Value under the key Key. If Key does not exist previously, it will record Value under Key in the record database. In the case of compound terms, all keys of the same name and arity are treated as equal.

Backtracking through a call of rerecord/2 does not undo erasure of the erased values and the value Value is not removed.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions

(4) instantiation fault
Key is not instantiated.
(5) type error
Key is neither atom, compound term, nor record handle.

Examples

   Success:
   [eclipse]: record(beer,lowenbrau),
   >        record(beer,paulaner),
   >        record(beer,spaten),
   >        rerecord(beer,guinness).
   yes.
   [eclipse]: recorded(beer,Value).
   Value = guinness     More? (;)
   no (more) solution.
   [eclipse]: erase_all(beer),rerecord(beer,guinness).
   yes.
   [eclipse]: recorded(beer,guinness).
   yes.
   Error:
   rerecord(Beer,anything).                (Error 4)
   rerecord(1,anything).                   (Error 5)
   rerecord(1.0,anything).                 (Error 5)
   rerecord("str",anything).               (Error 5)



See Also

erase_all / 1