with-compilation-unit ( quot -- )
Factor handbook » The implementation » Definitions » Compilation units

Next:with-nested-compilation-unit ( quot -- )


Vocabulary
compiler.units

Inputs
quota quotation


Outputs
None

Word description
Calls a quotation in a new compilation unit. The quotation can define new words and classes, as well as forget words. When the quotation returns, any changed words are recompiled, and changes are applied atomically.

Notes
Calls to with-compilation-unit may be nested.

The parser wraps every source file in a compilation unit, so parsing words may define new words without having to perform extra work; to define new words at any other time, you must wrap your defining code with this combinator.

Since compilation is relatively expensive, you should try to batch up as many definitions into one compilation unit as possible.

Definition