[ Term Manipulation | Reference Manual | Alphabetic Index ]

add_attribute(?Var, ?Attribute)

Add dynamically an attribute to a variable
Any term.
Any term.


Adds an attribute to a variable. The attribute name is taken as the name of the context module. There must have been an attribute declaration (meta_attribute/2) with the same name as the context module.

If Var is a free variable, it will be turned into an attributed variable with a single attribute Attribute whose name is the name of the context module. If Var is already an attributed variable with other attributes, then the new attribute will be added to it.

Otherwise, if the attribute slot is already occupied, or Var is already instantiated, then a new attributed variable with the single attribute Attribute is created, and subsequently unified with Var.

Use add_attribute/3 to add an explicitly named attribute.

Modes and Determinism


This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions

Fails if Var is not a free variable and its unification with the new attributed variable fails


(270) undefined variable attribute
There is no attribute declared in the context module.


[eclipse 6]: meta_attribute(eclipse, []).

[eclipse 3]: add_attribute(X, a), printf("%QPMw", X).
X{suspend : _g270 , a}
X = X

See Also

meta_attribute / 2, add_attribute / 3