C:
Factor documentation > Factor handbook > The language > Objects > Tuples > Tuple constructors
Prev:boa ( slots... class -- tuple )
Next:Parameterized constructors


Vocabulary
syntax

Syntax
C: constructor class


Inputs and outputs
constructora new word to define
classa tuple-class


Word description
Define a constructor word for a tuple class which simply performs BOA (by order of arguments) construction using boa.

Examples
Suppose the following tuple has been defined:
TUPLE: color red green blue ;

The following two lines are equivalent:
C: <color> color : <color> ( red green blue -- color ) color boa ;

In both cases, a word <color> is defined, which reads three values from the stack and creates a color instance having these values in the red, green and blue slots, respectively.

Definition
USING: classes.tuple parser ;

IN: syntax

SYNTAX: C: scan-new-word scan-word define-boa-word ;