[ Term Manipulation | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

add_attribute(?Var, ?Attribute)

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

Description

The main use of this predicate is for dynamic attributed variables creation. Since the number of declared extensions can vary with time, attributes explicitly occurring in the source of extensions might be created with less slots than currently necessary. To make sure that a newly created attributed variable will have as many slots as necessary, this predicate should be preferred to the equivalent

    Var = _{Attribute}
If Var is a free variable, it will be bound to a new attributed variable whose attribute corresponding to the caller module name will be Attribute. If Var is already an attributed variable and the corresponding attribute is a free variable, it will be bound to Attribute. Otherwise, if the attribute is not a free variable or if Var is instantiated, it will be unified with a new attributed variable whose corresponding attribute is Attribute and all other attributes are free variables.

Use add_attribute/3 to add an explicitly named attribute.

Modes and Determinism

Modules

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

Fail Conditions

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

Exceptions

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

Examples

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

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




See Also

meta_attribute / 2, add_attribute / 3