Term Modification

It is sometimes useful to change the value of instantiated variables.

Although, this is against the spirit of logic programming, it is sometimes useful. As in other Prolog systems, YAP has several primitives that allow updating Prolog terms. Note that these primitives are also backtrackable.

The setarg_51 "setarg/3" primitive allows updating any argument of a Prolog compound terms. The mutable family of predicates provides mutable variables. They should be used instead of setarg/3, as they allow the encapsulation of accesses to updatable variables. Their implementation can also be more efficient for long deterministic computations.

YAP also include non_backtrackable versions of these routines, that should be used with care.

Functions:

1. static Int p_setarg(USES_REGS1):

1. static Int p_create_mutable(USES_REGS1):

1. static Int p_get_mutable(USES_REGS1):

1. static Int p_update_mutable(USES_REGS1):

1. static Int p_is_mutable(USES_REGS1):

1. static Term NewTimedVar(CELL val USES_REGS):

1. Term Yap_NewTimedVar(CELL val):

1. Term Yap_NewEmptyTimedVar(void):

1. Term Yap_NewCompactTimedVar(Term v):

1. static Term ReadTimedVar(Term inv):

1. Term Yap_ReadTimedVar(Term inv):

1. static Term UpdateTimedVar(Term inv, Term new USES_REGS):

1. Term Yap_UpdateTimedVar(Term inv, Term new):

1. static Int nb_setarg(USES_REGS1):

1. static Int nb_set_shared_arg(USES_REGS1):

1. static Int nb_linkarg(USES_REGS1):

1. static Int nb_linkval(USES_REGS1):

1. void Yap_InitMaVarCPreds(void):