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.
Image Tuple examples

A parsing word defines tuple classes:
Image
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.
Image Slot accessors
Image Tuple constructors
Image Tuple subclassing
Image Tuple slot declarations
Image Protocol slots
Image Tuple introspection

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

Tuple literal syntax is documented in Tuple syntax.