Builtin predicates - Variable assignment

Predicates in this group are used to assign values to variables without unification, replacing their previous values. Variable assignment may be destructive [(:=)/2, (::=)/2] or back-trackable [(:==)/2, (::==)/2].

Destructive assignment is useful for setting object properties and temporary loop variables. Back-trackable assignment is recommended for use in code that is searching for a solution amongst alternatives so as to preserve logical consistency.

(:=)/2, (::=)/2, (:==)/2, (::==)/2


(:=)/2 - destructive variable assignment.

Usage
Var := Term
Description
Assigns a freshly renamed copy of Term to Var, replacing its previous value, and succeed. The Term is renamed so that the assigned value will survive back-tracking. Use (:==)/2 to cause Var to revert to its original value upon back-tracking.
Errors
Examples
 X := f(a, b)             succeeds
 X := f(b, a)             succeeds again, replacing the value
 X := f(X, a)             succeeds after renaming X to _X
 X := Y + Z               sets X to (_Y + _Z), does not evaluate
 X := pi                  sets X to the atom pi, does not evaluate
 X.name := 42             sets the name property of object X to 42
 a := X                   type_error(variable, a)
See Also
(::=)/2, (:==)/2, (::==)/2, (=)/2, copy_term/2

(::=)/2 - destructive variable assignment of an arithmetic term.

Usage
Var ::= Term
Description
Evaluates Term according to the rules of is/2, and assigns it to Var, replacing its previous value.
The assignment will be permanent; back-tracking will not revert Var to its previous value. Use (::==)/2 for back-trackable assignment.
Errors

The errors for is/2 may also be thrown during the evaluation of Term.

Examples
 X ::= X + 1              increments X
 X ::= pi                 sets X to 3.14159265358979323846
 X.name ::= 48 - 6        sets the name property of object X to 42
 a ::= X                  type_error(variable, a)
See Also
(:=)/2, (:==)/2, (::==)/2, is/2

(:==)/2 - back-trackable variable assignment.

Usage
Var :== Term
Description
Assigns Term to Var, replacing its previous value, and succeed. If Var occurs in Term, then the assignment will fail.
Upon back-tracking, Var will revert to its previous value. Use (:=)/2 for destructive assignment.
Errors
Examples
 X :== f(a, b)            succeeds
 X :== f(b, a)            succeeds again, replacing the value
 X :== f(X, a)            fails due to occurs check
 X :== Y + Z              sets X to (Y + Z), does not evaluate
 X :== pi                 sets X to the atom pi, does not evaluate
 X.name :== 42            sets the name property of object X to 42
 a :== X                  type_error(variable, a)
See Also
(:=)/2, (::=)/2, (::==)/2, (=)/2

(::==)/2 - back-trackable variable assignment of an arithmetic term.

Usage
Var ::== Term
Description
Evaluates Term according to the rules of is/2, and assigns it to Var, replacing its previous value.
Upon back-tracking, Var will revert to its previous value. Use (::=)/2 for destructive assignment.
Errors

The errors for is/2 may also be thrown during the evaluation of Term.

Examples
 X ::== X + 1
 X ::== pi
 X.name ::== 48 - 6       sets the name property of object X to 42
 a ::== X                 type_error(variable, a)
See Also
(:=)/2, (:==)/2, (::=)/2, is/2

Generated on 26 May 2011 for plang by  doxygen 1.6.1