16.1 Introduction
The attributed variable is a special ECLiPSedata type which
represents a variable together with attached attributes.
In the literature, attributed variables are sometimes referred to as
“metaterms”.
The name metaterm originates from its application in meta-programming:
for an object-level program, a metaterm looks like a variable, but for
a meta-program the same variable is just a piece of data which, possibly
together with additional meta-level information, forms the metaterm.
The attributed variable is a powerful means to implement various extensions of the
plain Prolog language.
In particular, it allows the system's behaviour
on unification to be customised.
In most situations, an attributed variable behaves like a normal
variable.
E.g. it can be unified with other terms and var/1 succeeds on it.
The differences compared to a plain variable are:
-
an attributed variable has a number of associated attributes
- the attributes are included in the module system
- when an attributed variable occurs in the unification and in some
built-in predicates, each attribute is processed by a user-defined
handler