]> gitweb.factorcode.org Git - factor.git/blob - core/handbook/compiler.facts
b9062e5c7fc48759acda6fd2bdec879aebdf1bd1
[factor.git] / core / handbook / compiler.facts
1 USING: help compiler parser ;
2
3 ARTICLE: "compiler" "The compiler"
4 "The Factor compiler transforms word definitions to native machine code and performs a variety of optimizations."
5 $terpri
6 "Only words for which a stack effect can be inferred will compile. All other words run in the interpreter. See " { $link "inference" } "."
7 { $subsection "compiler-usage" }
8 { $subsection "recompile" } ;
9
10 ARTICLE: "compiler-usage" "Compiler usage"
11 "The main entry point to the compiler is a single word taking a word as input:"
12 { $subsection compile }
13 "The above word throws an error if the word did not compile. Another variant simply prints the error and returns:"
14 { $subsection try-compile }
15 "The compiler can also compile a single quotation:"
16 { $subsection compile-quot }
17 { $subsection compile-1 }
18 "Two utility words for bulk compilation:"
19 { $subsection compile-vocabs }
20 { $subsection compile-all } ;
21
22 ARTICLE: "recompile" "Automatic recompilation"
23 "Factor's compiler performs " { $emphasis "early binding" } "; if a compiled word " { $snippet "A" } " calls another compiled word " { $snippet "B" } " and " { $snippet "B" } " is subsequently redefined, the compiled definition of " { $snippet "A" } " will still refer to the earlier compiled definition of " { $snippet "B" } "."
24 $terpri
25 "When a word is redefined, you can recompile all affected words automatically:"
26 { $subsection recompile }
27 "Normally loading a source file or a module also calls " { $link recompile } ". This can be disabled by wrapping file loading in a combinator:"
28 { $subsection no-parse-hook } ;