]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/annotations/annotations-docs.factor
factor: trim more using lists.
[factor.git] / basis / tools / annotations / annotations-docs.factor
1 USING: help.markup help.syntax words ;
2 IN: tools.annotations
3
4 ARTICLE: "tools.annotations" "Word annotations"
5 "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."
6 $nl
7 "Printing messages when a word is called or returns:"
8 { $subsections
9     watch
10     watch-vars
11 }
12 "Timing words:"
13 { $subsections
14     reset-word-timing
15     add-timing
16     word-timing.
17 }
18 "All of the above words are implemented using a single combinator which applies a quotation to a word definition to yield a new definition:"
19 { $subsections annotate }
20 { $warning
21     "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."
22 } ;
23
24 ABOUT: "tools.annotations"
25
26 HELP: annotate
27 { $values { "word" word } { "quot" { $quotation ( old-def -- new-def ) } } }
28 { $description "Changes a word definition to the result of applying a quotation to the old definition." }
29 { $notes "This word is used to implement " { $link watch } "." } ;
30
31 HELP: watch
32 { $values { "word" word } }
33 { $description "Annotates a word definition to print the data stack on entry and exit." } ;
34
35 { watch watch-vars reset } related-words
36
37 HELP: reset
38 { $values
39      { "word" word } }
40 { $description "Resets any annotations on a word." }
41 { $notes "This word will remove a " { $link watch } "." } ;
42
43 HELP: watch-vars
44 { $values
45      { "word" word } { "vars" "a sequence of symbols" } }
46 { $description "Annotates a word definition to print the " { $snippet "vars" } " upon entering the word. This word is useful for debugging." } ;
47
48 HELP: add-timing
49 { $values { "word" word } }
50 { $description "Adds timing code to a word, which records its total running time, including that of words it calls, on every invocation." }
51 { $see-also "timing" "tools.profiler.sampling" } ;
52
53 HELP: reset-word-timing
54 { $description "Resets the word timing table." } ;
55
56 HELP: word-timing.
57 { $description "Prints the word timing table." } ;
58
59 HELP: cannot-annotate-twice
60 { $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." } ;