The methods defined by Cat::BaseCategory are related to type conversion and equality testing, they are not related to an algebraic structure.
The implementation provided tries to convert x into an element of this domain by first calling dom::convert(x) and then, if this fails, x::dom::convert_to(x, dom); it retuns FAIL if both methods fail.
The implementation provided tries to convert x and y into elements of this domain and then calls dom::equal with these elements. It returns FAIL if the conversion fails or the equality test returns UNKNOWN.
Given a domain D, an expression of the form D(x,...) results in a call of the form D::new(x,...).
The implementation provided here tries to convert x by calling dom::convert(x) and returns the result. It raises an error if dom::convert returns FAIL.
Please do not print directly in this method by calling the function print for example!
The implementation provided here is dom::expr.
This method must return TRUE if it can decide that x is of type T, FALSE if it can decide that x is not of type T and FAIL if it can not decide the test.
This method is called in three different situations: Either if the argument x is of this domain, or if T is this domain, or if T is an element of this domain. Thus the following three situations can arise:
x is an element of the current domain.
In this case it must be tested if x may be regarded as an element of the type T, which may either be a domain or type expression. By default, this is only true if the domain type of x is T, or if T is a domain constructor for which x::dom::hasProp(x, T) is TRUE. In particular, x is, by default, not of type T if T is a type of the Type library.
T is the current domain.
In this case it must be tested if x may be regarded as an element of this domain. By the default implementation provided, this is TRUE only if the domain type of x is dom.
T is an element of the current domain.
In this case T is regarded as a type expression. The default implementation provided returns TRUE if the domain type of x is T, and FAIL if not. A special rule holds if T is a façade domain: in that case, coerce(x,T) is called, if this is successful TRUE is returned and FAIL if not.
When an expression new(D,x,...) is evaluated and D is a domain with method "new_extelement", then D::new_extelement(D,x,...) is evaluated and returned as result.
Kernel or façade domains must define this method because otherwise the function new would return a "container" element of D rather than a "raw" element as intended.
The implementation provided here returns the result of D::new(x,...).