T{
Factor handbook > The language > Syntax > Literals > Tuple syntax


Vocabulary
syntax

Syntax
T{ class } T{ class f slot-values... } T{ class { slot-name slot-value } ... }


Inputs and outputs
classa tuple class word
slotsslot values


Word description
Marks the beginning of a literal tuple.

Three literal syntax forms are recognized:
empty tuple form: if no slot values are specified, then the literal tuple will have all slots set to their initial values (see Initial values of slots).
BOA-form: if the first element of slots is f, then the remaining elements are slot values corresponding to slots in the order in which they are defined in the TUPLE: form.
assoc-form: otherwise, slots is interpreted as a sequence of { slot-name value } pairs. The slot-name should not be quoted.

BOA form is more concise, whereas assoc form is more readable for larger tuples with many slots, or if only a few slots are to be specified.

With BOA form, specifying an insufficient number of values is given after the class word, the remaining slots of the tuple are set to their initial values (see Initial values of slots). If too many values are given, an error will be raised.

Examples
An empty tuple; since vectors have their own literal syntax, the above is equivalent to V{ }
T{ vector }

A BOA-form tuple:
USE: colors T{ rgba f 1.0 0.0 0.5 }

An assoc-form tuple equal to the above:
USE: colors T{ rgba { red 1.0 } { green 0.0 } { blue 0.5 } }


See also
{, V{, H{, HS{, C{, }

Definition