Stack effect checking
Factor handbook ยป The language

Prev:Stack effect declarations
Next:Booleans


The Optimizing compiler checks the Stack effect declarations of words before they can be run. This ensures that words take exactly the number of inputs and outputs that the programmer declares in source.

Words that do not pass the stack checker are rejected and cannot be run, and so essentially this defines a very simple and permissive type system that nevertheless catches some invalid programs and enables compiler optimizations.

If a word's stack effect cannot be inferred, a compile error is reported. See Compiler errors.

The following articles describe how different control structures are handled by the stack checker.
Straight-line stack effects
Combinator stack effects
Recursive combinator stack effects
Branch stack effects

Stack checking catches several classes of errors.
Stack checker errors

Sometimes code with a dynamic stack effect has to be run.
Stack effect checking escape hatches

See also
Stack effect declarations, Stack effect tools, Batch error reporting