Next: 1.3 Execution Up: 1. Onyx Language Tutorial Previous: 1.1 Syntax Contents Index

# 1.2 Data types

Onyx includes a rich set of data types. In fact, Onyx code is represented as data, which means that there is a whole range of possibilities when writing Onyx programs that are difficult or impossible with compiled languages such as C. This aspect of Onyx is discussed in Section 1.10.

Onyx is dynamically typed, which means that errors due to object type incompatibilities are detected during program execution. For example, the following code will always run without an error, even though the arguments that would be passed to the add operator are invalid.

    false {
        `a string' [1] add
    }{
        `This is always printed' 1 sprint
    } ifelse

Dynamic typing has advantages in the flexibility that it offers, but it also means that type errors can go undetected in code for long periods of time before the invalid code is executed.

The Onyx type system is not extensible. There is no way to add new types in a program. However, there are techniques that can be combined with the built in types to simulate an extensible type system. For example, dictionaries can be created with, say, a `_type` field that indicates the type of the object:

    <
        $_type  $fraction
        $num    3
        $den    4
    >

Logical extensions of this can be used to create object hierarchies with single or multiple inheritance.

Next: 1.3 Execution Up: 1. Onyx Language Tutorial Previous: 1.1 Syntax Contents Index