Attribute names are linked to modules. This means that certain operations on attributed variables cause hooks to be called in the module whose name matches the attribute name.
- attr_unify_hook(+AttValue, +VarValue)
- A hook that must be defined in the module to which an attributed variable refers. It is called after the attributed variable has been unified with a non-var term, possibly another attributed variable. AttValue is the attribute that was associated to the variable in this module and VarValue is the new value of the variable. Normally this predicate fails to veto binding the variable to VarValue, forcing backtracking to undo the binding. If VarValue is another attributed variable the hook often combines the two attributes and associates the combined attribute with VarValue using put_attr/3.
- attr_portray_hook(+AttValue, +Var)
- Called by write_term/2
and friends for each attribute if the option
attributes(portray)is in effect. If the hook succeeds the attribute is considered printed. Otherwise
Module = ...is printed to indicate the existence of a variable. New infrastructure dealing with communicating attribute values must be based on copy_term/3 and its hook attribute_goals/3.
- This nonterminal, if it is defined in a module, is used by copy_term/3 to project attributes of that module to residual goals. It is also used by the top level to obtain residual goals after executing a query.