Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Cat::BaseCategory

Base category

Description

Cat::BaseCategory is the most general super-category of all categories defined by the Cat package. Any domain in the Dom package is of this category.

The methods defined by Cat::BaseCategory are related to type conversion and equality testing, they are not related to an algebraic structure.

Methods

expand all

Basic Methods

convert(x)

convert_to(x, T)

equal(x, y)

Note that this method does not overload the function _equal, i.e. the = operator. The function _equal cannot be overloaded.

expr(x)

Conversion Methods

coerce(x)

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.

equiv(x, y)

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.

new(x)

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.

print(x)

Please do not print directly in this method by calling the function print for example!

The implementation provided here is dom::expr.

testtype(x, T)

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.

Technical Methods

new_extelement(x, …)

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,...).

Was this topic helpful?