Menu

Defining structures

Mark Anthony Taylor (Shyreman)

Structures are C-compatible sequences of fields. Each field is either a primitive type or a
structure type.

(struct
    (<field_type1> <field_name1>)
        ...
    (<field_typeN> <field_nameN>)
)

Example:

(struct Vector4f
    (Float32 x)
    (Float32 y)
    (Float32 z)
    (Float32 w)
)    // defines a four component structure with fields x, y, z and w, in that order.

It is legal to specify more than one field name for a given type and definition:

(struct Vec3d
    (Float64 x y z) // defines a three component structure with fields x, y and z, in that order.
)

Structures can be aliased into a namespace using the alias directive.

A structure definition creates a new type which itself may become part of a field definition of another structure.

(struct Matrix4x4f
    (Vector4f row1 row2 row3 row4)
)

Related

Wiki: Content

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.