Previous Up Next

17.5  Decomposing Attributed Variables

The attributes of an attributed variable can be accessed using one-way unification in a matching clause, e.g.,

    get_attribute(X{Name:Attribute}, A) :-
        -?->
        A = Attribute.

This clause succeeds only when the first argument is an attributed variable, and it binds X to the whole attributed variable and A to the attribute whose name is the instantiation of Name. Note that a normal (unification) clause can not be used to decompose an attributed variable (it would create a new attributed variable and unify this with the caller argument, but the unification is handled by an attributed variable handler, see Section 17.7).


Previous Up Next