TypeTools
AddType
extend type system with user-defined type
Calling Sequence
Parameters
Description
Examples
AddType(typename, handler)
typename
-
symbol; name of the type
handler
procedure or structured type
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 typeexpr,typename results in a call to handlerexpr. Additional arguments can be passed to handler from a type call of the form typeexpr,typenamearg1,arg2,..., which results in the call handlerexpr,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.
TypeToolsAddTypetff,identicalFAIL,identicalfalse,identicaltrue
typeFAIL,tff
true
typetrue,false,listtff
TypeToolsAddTypeinteger7,t↦evalbt::integerandiremt,7=0
type4,integer7
false
type28,integer7
TypeTools[AddType]( pair, proc( expr, elementtype := anything ) type( expr, [ elementtype, elementtype ] ) end proc ):
type2,x,pair
type2,x,pairinteger
type2,3,pairinteger
See Also
type
type[structured]
TypeTools[GetType]
TypeTools[RemoveType]
Download Help Document