donotturnoff

Rex type documentation

Introduction

Rex has a rigid type system and a hierarchical type structure. This document aims to provide a reference about Rex's types for Rex programmers.

Casting between types is provided by the cast library.

Type hierarchy

Types in Rex are hierarchical. The tree below shows the structure of the hierarchy.

This hierarchical structure means that, for instance, an int is a subtype of num, and as such, any function which takes parameters of type num can also take parameters of type int - but not the other way around.

Descriptions of types

type
This is the root type from which all other types descend.
num
This is a general numerical type. It is essentially equivalent to float at the moment, but may change to accommodate complex numbers in the future. All other numerical types descend from num.
int
This is an integral numerical type which can represent all integers supported by the system; negative, positive or zero.
whole
This is an integral numerical type which only represents integers which are positive or zero (the whole numbers).
natural
This is an integral numerical type which only represents the positive integers (the natural numbers).
float
This is a numerical type which can represent any floating-point number supported by the system. This means that, in the current implementation of Rex, all numbers which can be represented in Rex can be represented by the float type, but this may change in the future so it is its own type.
str
This is a string type, for representing strings of characters (text).
bool
This is a Boolean type, for representing True or False.
null
This is an empty type. null represents nothing and is useful in cases where a function returns no value.

To do: explain err and its subtypes