7.5 Type testing

To check whether a given OZ_Term is a certain Oz value several functions are provided:

OZ_isAtom
OZ_isBool
OZ_isCell
OZ_isThread
OZ_isPort
OZ_isChunk
OZ_isDictionary
OZ_isCons
OZ_isFalse
OZ_isFeature
OZ_isFloat
OZ_isInt
OZ_isBigInt
OZ_isSmallInt
OZ_isNumber
OZ_isLiteral
OZ_isName
OZ_isNil
OZ_isObject
OZ_isPair
OZ_isPair2
OZ_isProcedure
OZ_isRecord
OZ_isTrue
OZ_isTuple
OZ_isUnit
OZ_isValue
OZ_isVariable
OZ_isBitString
OZ_isByteString
OZ_isFSetValue

All these functions have the same signature. For example OZ_isAtom is declared as int OZ_isAtom(OZ_Term t)

All type tests return nonzero iff their argument is of the respective type.

A few of these need some more explanation:

int OZ_isBigInt(OZ_Term t)
int OZ_isSmallInt(OZ_Term t)

The emulator has two representations for integers: small integers and big integers. Small integers are implemented very efficiently.

int OZ_isPair(OZ_Term t)

Returns zero iff t is a tuple with label #.

int OZ_isPair2(OZ_Term t)

Returns nonzero iff t is a tuple with label # and arity of 2.

int OZ_isValue(OZ_Term t)

Returns nonzero iff t is not a variable.

int OZ_isVariable(OZ_Term t)

Returns nonzero iff t is a variable.

OZ_isList

int OZ_isList(OZ_Term termOZ_Term *var)

Returns nonzero iff term is a list. If term is no list, but the tail is a variable, then *var is set to the tail of the list, else it is set to null. var may be null. If term is cyclic then OZ_isList never terminates!

OZ_isString

int OZ_isString(OZ_Term termOZ_Term *var)

Returns nonzero iff term is an Oz string. If term is no string, but the tail or an element of the list is a variable, then *var is set to this variable, else it is set to null. var may be null. If term is cyclic then OZ_isString never terminates!

OZ_isVirtualString

int OZ_isVirtualString(OZ_Term termOZ_Term *var)

Returns nonzero iff term is a virtual string. If term is no virtual string, but contains a variable, then *var is set to this variable, else it is set to null. var may be null. If term is cyclic then OZ_isVirtualString never terminates!

OZ_termType

OZ_Term OZ_termType(OZ_Term t)

Returns an atom describing the type of t. The following types are returned:

variable, intfloat, atom, name, tuple, record, fset,
foreignPointer, procedure, cell, space, object, port,
chunk, array, dictionary, lock class, resource

(see also Value.type in Section 3.2 of ``The Oz Base Environment'').


Michael Mehl, Tobias Müller, Christian Schulte and Ralf Scheidhauer
Version 1.4.0 (20080702)