Word properties
Factor handbook » The language » Words

Prev:Word introspection

Each word has a hashtable of properties.
word-prop ( word name -- value )

set-word-prop ( word value name -- )

The stack effect of the above two words is designed so that it is most convenient when name is a literal pushed on the stack right before executing this word.

The following are some of the properties used by the library:
"declared-effect"Stack effect declarations
"inline", "foldable", "flushable", "recursive"Compiler declarations
"help", "help-loc", "help-parent"Where word help is stored - Writing documentation
"intrinsic"Quotation run by the compiler during cfg building to emit the word inline.
"loc"Location information - where
"methods", "combination"Set on generic words - Generic words and methods
"outputs", "input-classes", "default-output-classes"A bunch of metadata used during the value propagation step of the compilation to produce type-optimized code.
"parsing"Parsing words
"predicating"Set on class predicates, stores the corresponding class word.
"reading", "writing"Set on slot accessor words - Low-level slot operations
"specializer"Compiler specialization hints
"dependencies", Used by the optimizing compiler when forgetting words for fast dependency lookup. See Compilation units.
"generic-call-sites"Set on some generic words.

Properties which are defined for classes only:
"class"A boolean indicating whether this word is a class - Classes
"coercer"A quotation for converting the top of the stack to an instance of this class
"constructor"Tuple constructors
"type"Built-in classes
"superclass", "predicate-definition"Predicate classes
"members"Union classes, Maybe classes
"instances"Lists the instances of the mixin class and where they are defined - Mixin classes
"predicate"A quotation that tests if the top of the stack is an instance of this class - Class predicate words
"slots"Low-level slot operations
"superclass", "predicate-definition"Predicate classes
"type"Built-in classes