Tuples
Factor handbook > The language > Objects

Prev:Classes
Next:Generic words and methods


Tuples are user-defined classes composed of named slots. They are the central data type of Factor's object system.
Tuple examples

A parsing word defines tuple classes:
TUPLE:


For each tuple class, several words are defined, the class word, a class predicate, and accessor words for each slot.

The class word is used for defining methods on the tuple class; it has the same name as the tuple class. The predicate is named name?. Initially, no specific words are defined for constructing new instances of the tuple. Constructors must be defined explicitly, and tuple slots are accessed via automatically-generated accessor words.
Slot accessors
Tuple constructors
Tuple subclassing
Tuple slot declarations
Protocol slots
Tuple introspection

Tuple classes can be redefined; this updates existing instances:
Tuple redefinition

Tuple literal syntax is documented in Tuple syntax.