AddType - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


TypeTools

  

AddType

  

extend type system with user-defined type

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AddType(typename, handler)

Parameters

typename

-

symbol; name of the type

handler

-

procedure or structured type

Description

• 

A new type typename is installed in the type system.

• 

The handler argument is either a procedure or a structured type describing the new type.

• 

If handler is a procedure, then a type call of the form type⁡expr,typename results in a call to handler⁡expr. Additional arguments can be passed to handler from a type call of the form type⁡expr,typename⁡arg1,arg2,..., which results in the call handler⁡expr,arg1,arg2,.... The handler argument, if it is a procedure, must return either true or false; no other return value is acceptable. It must also be prepared to handle any argument sequence that is passed to it.

• 

If the handler argument is a structured type, then the type test is defined by the structured type interpreter as though the structured type were used directly in a call to type.

• 

The AddType command returns NULL.

Examples

> 

TypeToolsAddType⁡tff,identical⁡FAIL,identical⁡false,identical⁡true

> 

type⁡FAIL,tff

true

(1)
> 

type⁡true,false,list⁡tff

true

(2)
> 

TypeToolsAddType⁡integer7,t↦evalb⁡t::integerandirem⁡t,7=0

> 

type⁡4,integer7

false

(3)
> 

type⁡28,integer7

true

(4)
> 

TypeTools[AddType]( pair, proc( expr, elementtype := anything )
    type( expr, [ elementtype, elementtype ] )
end proc ):

> 

type⁡2,x,pair

true

(5)
> 

type⁡2,x,pair⁡integer

false

(6)
> 

type⁡2,3,pair⁡integer

true

(7)

See Also

type

type[structured]

TypeTools

TypeTools[GetType]

TypeTools[RemoveType]