Low-level slot operations
Factor handbook » The language » Objects

Prev:Mirrors


The slots vocabulary contains words for introspecting the slots of an object. A slot is a component of an object which can store a value.

Tuples are composed entirely of slots, and instances of Built-in classes consist of slots together with intrinsic data.

The "slots" word property of built-in and tuple classes holds an array of slot specifiers describing the slot layout of each instance.
slot-spec


The four words associated with a slot can be looked up in the accessors vocabulary:
reader-word ( name -- word )

writer-word ( name -- word )

setter-word ( name -- word )

changer-word ( name -- word )


Looking up a slot by name:
slot-named ( name specs -- spec/f )


Defining slots dynamically:
define-reader ( class slot-spec -- )

define-writer ( class slot-spec -- )

define-setter ( name -- )

define-changer ( name -- )

define-slot-methods ( class slot-spec -- )

define-accessors ( class specs -- )


Unsafe slot access:
slot ( obj m -- value )

set-slot ( value obj n -- )


See also
Slot accessors, Mirrors