A suspension variable, or an attributed variable, is a variable to which suspended agents and attribute values are attached. Agents are registered onto suspension variables by action rules. Each attribute has a name, which must be ground, and a value. The built-in put_attr(Var,Attr,Value) is used to register attribute values, and the built-in get_attr(Var,Attr,Value) is used to retrieve attribute values.
Due to attributed variables, the unification procedure must be revisited. When a normal Prolog variable is unified with an attributed variable, the normal Prolog variable will be bound to the attributed variable. When two attributed variables Y and O are unified, supposing that Y is younger than O, the following operations will be performed:
Note that, because no attributes are copied, the younder variable will lose all of its attributes after unification. Also note that, because of garbage collection, the age ordering of variables is normally unpredicatable.
- All of the agents that are attached to Y are copied to O.
- An event, ins(Y), is posted.
- The variable Y is set to reference the variable O.
- attvar(Term): This predicate is true if Term is an attributed variable.
- put_attr(Var, Attr, Value): Sets the value for the attribute named Attr to Value. If an attribute with the same name already exists on Var, the old value is replaced. The setting is undone upon backtracking, as in setarg/3. This primitive also attaches an agent to Var, which invokes attr_unify_hook/3 when ins(Var) is posted.
- put_attr_no_hook(Var, Attr, Value): This is the same as put_attr(Var, Attr, Value), except that it does not attach any agent to Var to call attr_unify_hook/3 when ins(Var) is posted.
- get_attr(Var, Attr, Value): Retrieves the current value for the attribute named Attr. If Var is not an attributed variable, or if no attribute named Attr exists on Var, this predicate silently fails.
- del_attr(Var, Attr): Deletes the attribute named Attr. This update is undone upon backtracking.
The list of all suspended agents is L.
The list of suspended agents on the suspension variable V is L.
N is the number of agents that are attached to the suspension variable X.