Type defines set of values. Variable of given type can hold one of the values from this set. Types are organized into basic classes, type object is parametrization of a type class.

For example Int 9..11 is parametrization of type class Int. Such type can contain only value 9, 10 or 11.

Picture: Relationship between class, type and value

Type definition purpose:


Value represents a value in the system. It is defined as union of pointer/integer. Minimal size of the value is 32 bits. On 64bit systems, it will be 64 bits. Value does not encode type (we always have to work with value/type tuple.

Type interface

Type interface is implemented by type provider. By implementing the type interface, you can provide new class of values.

void TypeFree(VoidPtr type)

Free all resources associated with specified type.

Bool TypeContainsValue(VoidPtr type, Value val)

Return true, if specified value may be contained in variable of specified type. Value is guaranteed to be of same class.

Bool TypeContainsType(VoidPtr type, Type * subtype)

Return true, if all values storable in subtype can be stored in specified type too.

void TypeValueFree(Value val)

Free value of specified type.

Value TypeValueCopy(Value val)

Create copy of the value of this type.

Error TypeValueCharsOut(VoidPtr type, Value val, VoidPtr format, WriteFn write_fn, VoidPtr medium)

Write the value as text.