Mutable Terms

Author(s): Rémy Haemmerlé.

Version: 2.0 (2010/8/9) 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 which does not have safe semantics.

Usage and interface

Documentation on exports

PREDICATE

Usage: create_mutable(Datum,Mutable)

  • Description: Unifies Datum with a freshly created mutable term with initial value Datum.

PREDICATE

Usage: get_mutable(Datum,Mutable)

  • Description: Unifies Datum with the current value of the mutable term Mutable. Mutable must be a mutable term.

PREDICATE

Usage: update_mutable(Datum,Mutable)

  • Description: Updates the current value of the mutable term Mutable to become Datum. Mutable must be a mutable term.

PREDICATE

Usage: mutable(Term)

  • Description: Succeeds if Term is currently instantiated to a mutable term.