This module provides a type 1 interface to attributed variables. The trailed state of the at-tributed variable is modelled as key value pairs and can be accessed and modified by the predicates put_attr/3, get_attr/3 and del_attr/2. When an attributed variable with type 1 state gets instantiated a call to the attributed variable unify hooks gets scheduled.Examples:
foo:attr_unify_hook(L, _) :- write('L='), write(L), nl.
?- put_attr(X, foo, [X,Y]), put_attr(Y, foo, [X,Y]), [X,Y]=[1,2].
?- put_attr(X, foo, [X,Y]), put_attr(Y, foo, [X,Y]), X=Y.
The unify hook attr_unify_hook/2 has to be declared inside the module of the key. The scheduled hook is called after the variable has been instantiated and at the next calls port if the surrounding unification was successful. The hook is allowed to fail or to succeed non-deterministically.
The goals hook attribute_goals/3 has to be optionally declared inside the module of the key. When needed the hook is called only once. If the hook is missing or if it fails a single goal for a put_attr/3 call is generated. The goals are used in the top-level display of answers and they can be retrieved by the call_residue/2 predicate from the module residue.
The following unify predicates are provided.