Compiler declarations
Factor handbook » The language » Words

Prev:Deferred words and mutual recursion
Next:Word introspection

Compiler declarations are parsing words that set a word property in the most recently defined word. They appear after the final ; of a word definition:
: cubed ( x -- y ) dup dup * * ; foldable

Compiler declarations assert that the word follows a certain contract, enabling certain optimizations that are not valid in general.




It is entirely up to the programmer to ensure that the word satisfies the contract of a declaration. Furthermore, if a generic word is declared foldable or flushable, all methods must satisfy the contract. Unspecified behavior may result if a word does not follow the contract of one of its declarations.

See also
Stack effect declarations