subtype - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Type Checking : subtype

subtype

test whether one type is a subtype of another

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

subtype(s, t)

Parameters

s

-

any Maple type

t

-

any Maple type

Description

• 

A type s is said to be a subtype of a type t if for every expression e the test type(e, s) evaluates to true, then the expression type(e, t) will also evaluate to true. If a type is identified with its extension, then the ``subtype'' relation is the relation of inclusion.

• 

The subtype(s, t) function attempts to determine if the type s is a subtype of the type t.

• 

If subtype can prove that s is a subtype of t, then the value true is returned. In the same manner, if subtype can prove that s is not a subtype of t, then the value false is returned. Otherwise, if it is not possible to compute whether one type is a subtype of another, the value FAIL is returned.

  

In general, it is not possible to compute whether one type is a subtype of another.

  

Note: Not all pairs of types are comparable. For example, the types list and set are disjoint types; no expression is both a list and a set. Thus, both subtype( 'set', 'list' ) and subtype( 'list', 'set' ) return false.

Examples

subtype'integer','rational'

true

(1)

subtype'polynom','string,algebraic'

true

(2)

subtype'Andname,algebraic','name'

true

(3)

subtype'vectorinteger','vectorrational'

true

(4)

subtype'vector2,integer','vectorrational'

true

(5)

subtype'vector2,integer','vector2,rational'

true

(6)

subtype'vector2,integer','vector2'

true

(7)

See Also

ExtendingMaple

type

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam