This defines a domain. A domain definition is a ground structure with atomic arguments. The structure's functor name is taken as the name of the domain. The domain name is used e.g. for declaring domain variables in lib(ic_symbolic).
The structure's arguments are the domain values. A domain value can be any atomic term (atom, string, number), but will usually be an atom. Domains are ordered, and the argument order in the defining structure implies the order of the domain values. The domain values are mapped to natural numbers, with the first argument being mapped to 1, the second to 2 and so on.
After having been defined, the mapping can be looked up via the primitives domain_index/3 and current_domain/3. Certain libraries (e.g. lib(ic_symbolic)) use the defined mapping internally.
Domain definitions can be local or exported. The domain values of all visible domain definitions within a module must be mutually exclusive, i.e. there must not be any ambiguity as to which domain a particular value belongs to. The system checks this condition whenever new domains are defined or imported.
:- local domain(colour(red,green,blue)). :- export domain(vowel(a,e,i,o,u)). :- local domain(abc(a,b,c)). Domain value a not unique in module eclipse out of range in local domain(abc(a, b, c)) Abort ?- current_domain(Name, DefModule, Def). Name = colour DefModule = eclipse Def = colour(red, green, blue) More (0.00s cpu) ? ; Name = vowel DefModule = eclipse Def = vowel(a, e, i, o, u) More (0.00s cpu) ? ; No (0.00s cpu) ?- domain_index(blue, Domain, Index). Domain = eclipse : colour Index = 3 Yes (0.00s cpu) ?- domain_index(o, Domain, Index). Domain = eclipse : vowel Index = 4 Yes (0.00s cpu) ?- domain_index(yellow, Domain, Index). No (0.00s cpu)