TUPLE:
Factor handbook » The language » Objects » Tuples

Prev:Tuple examples
Next:Slot accessors


Vocabulary
syntax

Syntax
TUPLE: class slots... ; TUPLE: class < superclass slots ... ;


Inputs
None

Outputs
None

Word description
Defines a new tuple class.

The superclass is optional; if left unspecified, it defaults to tuple.

Slot specifiers take one of the following three forms:
name - a slot which can hold any object, with no attributes
{ name attributes... } - a slot which can hold any object, with optional attributes
{ name class attributes... } - a slot specialized to a specific class, with optional attributes

Slot attributes are lists of slot attribute specifiers followed by values; a slot attribute specifier is one of initial: or read-only. See Tuple slot declarations for details.

Examples
A simple tuple class:
TUPLE: color red green blue ;

Declaring slots to be integer-valued:
TUPLE: color { red integer } { green integer } { blue integer } ;

An example mixing short and long slot specifiers:
TUPLE: person { age integer initial: 0 } { department string initial: "Marketing" } manager ;


See also
tuple-class, define-tuple-class

Definition