]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/annotations/annotations-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor into constraints
[factor.git] / basis / tools / annotations / annotations-docs.factor
1 USING: help.markup help.syntax words parser quotations strings
2 system sequences ;
3 IN: tools.annotations
4
5 ARTICLE: "tools.annotations" "Word annotations"
6 "The word annotation feature modifies word definitions to add debugging code. You can restore the old definition by calling " { $link reset } " on the word in question."
7 $nl
8 "Printing messages when a word is called or returns:"
9 { $subsection watch }
10 { $subsection watch-vars }
11 "Timing words:"
12 { $subsection reset-word-timing }
13 { $subsection add-timing }
14 { $subsection word-timing. }
15 "All of the above words are implemented using a single combinator which applies a quotation to a word definition to yield a new definition:"
16 { $subsection annotate }
17 { $warning
18     "Certain internal words, such as words in the " { $vocab-link "math" } ", " { $vocab-link "sequences" } " and UI vocabularies, cannot be annotated, since the annotated code may end up recursively invoking the word in question. This may crash or hang Factor. It is safest to only define annotations on your own words."
19 } ;
20
21 ABOUT: "tools.annotations"
22
23 HELP: annotate
24 { $values { "word" "a word" } { "quot" { $quotation "( old-def -- new-def )" } } }
25 { $description "Changes a word definition to the result of applying a quotation to the old definition." }
26 { $notes "This word is used to implement " { $link watch } "." } ;
27
28 HELP: watch
29 { $values { "word" word } }
30 { $description "Annotates a word definition to print the data stack on entry and exit." } ;
31
32 { watch watch-vars reset } related-words
33
34 HELP: reset
35 { $values
36      { "word" word } }
37 { $description "Resets any annotations on a word." }
38 { $notes "This word will remove a " { $link watch } "." } ;
39
40 HELP: watch-vars
41 { $values
42      { "word" word } { "vars" "a sequence of symbols" } }
43 { $description "Annotates a word definition to print the " { $snippet "vars" } " upon entering the word. This word is useful for debugging." } ;
44
45 HELP: add-timing
46 { $values { "word" word } }
47 { $description "Adds timing code to a word, which records its total running time, including that of words it calls, on every invocation." }
48 { $see-also "timing" "profiling" } ;
49
50 HELP: reset-word-timing
51 { $description "Resets the word timing table." } ;
52
53 HELP: word-timing.
54 { $description "Prints the word timing table." } ;
55
56 HELP: cannot-annotate-twice
57 { $error-description "Thrown when attempting to annotate a word that's already been annotated. If a word already has an annotation such as a watch or a breakpoint, you must first " { $link reset } " the word before adding another annotation." } ;