Tuple introspection - Factor Documentation (original) (raw)

In addition to the slot reader and writer words which TUPLE: defines for every tuple class, it is possible to construct and take apart entire tuples in a generic way.
>tuple ( seq -- tuple )
tuple>array ( tuple -- array )
tuple-slots ( tuple -- seq )
slots>tuple ( seq class -- tuple )

Tuples can be compared for slot equality even if the tuple class overrides equal?:

tuple= ( tuple1 tuple2 -- ? )

Tuple classes can also be defined at run time:

define-tuple-class ( class superclass slots -- )

See also
Low-level slot operations, Mirrors