Mutable Terms
Author(s): Rémy Haemmerlé.
This module provides mutable terms i.e. an abstract datatype provides with efficient backtrackable destructive assignment. In other words, any destructive assignments are transparently undone on backtracking. Modifications that are intended to survive backtracking must be done by asserting or retracting dynamic program clauses instead. Mutable must be prefered to destructive assignment of arbitrary terms using setarg/3 of the module odd which does not have safe semantics.
Usage and interface
- Library usage:
:- use_module(library(mutables)). - Exports:
- Predicates:
create_mutable/2, get_mutable/2, update_mutable/2, mutable/1.
- Predicates:
- Imports:
- System library modules:
odd. - Packages:
prelude, nonpure, assertions.
- System library modules:
Documentation on exports
Usage:create_mutable(Datum,Mutable)
Unifies Datum with a freshly created mutable term with initial value Datum.
Usage:get_mutable(Datum,Mutable)
Unifies Datum with the current value of the mutable term Mutable. Mutable must be a mutable term.
Usage:update_mutable(Datum,Mutable)
Updates the current value of the mutable term Mutable to become Datum. Mutable must be a mutable term.
Usage:mutable(Term)
Succeeds if Term is currently instantiated to a mutable term.