Did you know ... Search Documentation:
Pack lib_atts -- prolog/atts.pl
PublicShow source
 attribute(+AttributeSpec)
:- attribute AttributeSpec,..., AttributeSpec.

where each AttributeSpec has the form Functor/Arity. Having declared some attribute names, these attributes can be added, updated and deleted from unbound variables using the following two predicates (get_atts/2 and put_atts/2) defined in the module atts. For each declared attribute name, any variable can have at most one such attribute (initially it has none).

 put_atts(+Var, +AccessSpec)
Sets the attributes of Var according to AccessSpec.

Non-variable terms in Var cause a type error. if curent_prolog_flag(atts_compat,xsb).

The effect of put_atts/2 are undone on backtracking. (prefix + may be dropped for convenience). The prefixes of AccessSpec have the following meaning: +(Attribute): The corresponding actual attribute is set to Attribute. If the actual attribute was already present, it is simply replaced. -(Attribute): The corresponding actual attribute is removed. If the actual attribute is already absent, nothing happens.

Should we ignore The arguments of Attribute, only the name and arity are relevant? Currently coded to

== ?- m1:put_atts(Var,+a(x1,y1)). put_attr(Var, m1, [a(x1, y1)]).

?- m1:put_atts(V,+a(x1,y1)),m1:put_atts(V,+b(x1,y1)),m1:put_atts(V,-a(_,_)),m2:put_atts(V,+b(x2,y2)). put_attr(V, m1, [b(x1, y1)]), put_attr(V, m2, [b(x2, y2)]) .

 get_atts(+Var, ?AccessSpec)
Gets the attributes of Var according to AccessSpec. If AccessSpec is unbound, it will be bound to a list of all set attributes of Var.

Non-variable terms in Var cause a type error. if curent_prolog_flag(atts_compat,xsb).

AccessSpec is either +(Attribute), -(Attribute), or a list of such (prefix + may be dropped for convenience).

The prefixes in the AccessSpec have the following meaning: +(Attribute): The corresponding actual attribute must be present and is unified with Attribute. -(Attribute): The corresponding actual attribute must be absent.

Should we ignore The arguments of Attribute are ignored, only the name and arity are relevant? yes = XSB_compat, no = less control and perf

?- m1:put_atts(Var,+a(x1,y1)),m1:get_atts(Var,-missing(x1,y1)).
put_attr(Var, m1, [a(x1, y1)]).

?- m1:put_atts(Var,+a(x1,y1)),m1:get_atts(Var,X).
X=[a(x1, y1)],
put_attr(Var, m1, [a(x1, y1)]).

TODO/QUESTION user:get_atts(Var,Atts) -> ??? only attributes in 'user' or all attributes??? Attr=[m1:...]

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 set_dict_atts_reader(Arg1)
 dict_to_attvar(Arg1, Arg2)
 dict_to_attvar(Arg1, Arg2, Arg3)