Next: , Previous: , Up: Top   [Index]


9 Attributed meta programming

attributes are basically a method to attache meta data to a prolog variable and customize the unification between attributes and other data structures, we will describe the interface. Attributing means that the variable has an explicit special datastructure and any lookup will get stuck on that datastructure although the attribute is bound to a value, this basically means that the attribute variable value need to be peeked at. The data an attribute has is essentially the underlying data and then a list of identifiers plus meta data, the identifiers identifying a certain type of attribute and also at the same time is the stub that is called at unification. Currently ther eis weak support for handling attributed variables in e.g. the utility functions. One need to explicitly get the raw value in case of attributed variables in these functions arguments so currently this feature is a bit experimental. Here is the interface in guile log.,

G.L. (<attvar?> x), sucesses if x is either a normal variable or an attributed variable.

G.L. (<attvar-raw?> x), success if x is only an attributed variable.

G.L. (<put-attr> x m v), puts on an attributed variable x, the attributed indentity m and meta data v. m has the signature

G.L. (m a1 a2 unify?), if unify? is true then the code should unify a1,a2 with the appropriate customized algorithm e.g. prolog’s =, else if false then the it should berform an identity comparison e.g. prologs ==.

G.L. (<get-attr> x m v), get the attributed var x, meta data unified to v for attribute identity m.

G.L. (<del-attr> x m), remove the attributed variable x, attribute m.

G.L. (<raw-attvar> x)), get the underlying variable value associated to the attributed variable x.


Next: , Previous: , Up: Top   [Index]