
domattr - access to the contents of a domain

Calling sequence:
domattr(dom, expr)

Parameter:
dom    --  domain or domain element
expr   --  expression

Summary:

Similar to a table, a domain contains entries that can be accessed with
indicies.

domattr(dom, expr) returns the entry of dom with the index expr. If dom
has no entry with this index then the function returns FAIL. If the parameter
dom is not a domain but an element of one then dom is replaced by the relevant
domain and the operation is carried out on this.

If this function occurs on the left side of an assignment the right side of the
assignment is inserted in dom under the index expr. Here the function does
not copy the domain and side-effects can occur: i.e. the domain is changed
in every datum that it contains. Through this characteristic it is possible for
a domain to contain itself as a sub-domain.

The operator :: exists for this function. The parser automatically converts
an entry of the form x::y into the call domattr(x,"y"). The value after the
colons must be either a variable or a keyword. Please note that the variable
after the colons is converted into a string! domattr is a kernel function.

>>  d1:=domain(): d2:=d1: d2::x:=y: d1::x;

      y

>>  d:=domain(table("x"=y)): d::x;

      y

>>  d:=domain(table("x"=y)): e:=new(d): e::x;

      y

See also:  domain

