]> gitweb.factorcode.org Git - factor.git/blob - basis/listener/listener-docs.factor
Merge branch 'master' into startup
[factor.git] / basis / listener / listener-docs.factor
1 USING: help.markup help.syntax kernel io system prettyprint continuations ;
2 IN: listener
3
4 ARTICLE: "listener-watch" "Watching variables in the listener"
5 "The listener prints the concepts of the data and retain stacks after every expression. It can also print values of dynamic variables which are added to a watch list:"
6 { $subsections visible-vars }
7 "To add or remove a single variable:"
8 { $subsections
9     show-var
10     hide-var
11 }
12 "To add and remove multiple variables:"
13 { $subsections
14     show-vars
15     hide-vars
16 }
17 "Hiding all visible variables:"
18 { $subsections hide-all-vars } ;
19
20 HELP: only-use-vocabs
21 { $values { "vocabs" "a sequence of vocabulary specifiers" } }
22 { $description "Replaces the current manifest's vocabulary search path with the given set of vocabularies." } ;
23
24 HELP: show-var
25 { $values { "var" "a variable name" } }
26 { $description "Adds a variable to the watch list; its value will be printed by the listener after every expression." } ;
27
28 HELP: show-vars
29 { $values { "seq" "a sequence of variable names" } }
30 { $description "Adds a sequence of variables to the watch list; their values will be printed by the listener after every expression." } ;
31
32 HELP: hide-var
33 { $values { "var" "a variable name" } }
34 { $description "Removes a variable from the watch list." } ;
35
36 HELP: hide-vars
37 { $values { "seq" "a sequence of variable names" } }
38 { $description "Removes a sequence of variables from the watch list." } ;
39
40 HELP: hide-all-vars
41 { $description "Removes all variables from the watch list." } ;
42
43 ARTICLE: "listener" "The listener"
44 "The listener evaluates Factor expressions read from a stream. The listener is the primary interface to the Factor runtime. Typically, you write Factor code in a text editor, then load it using the listener and test it."
45 $nl
46 "The classical first program can be run in the listener:"
47 { $example "\"Hello, world\" print" "Hello, world" }
48 "Multi-line expressions are supported:"
49 { $example "{ 1 2 3 } [\n    .\n] each" "1\n2\n3" }
50 "The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them."
51 $nl
52 "The listener will display the current contents of the datastack after every expression is evaluated. The listener can additionally watch dynamic variables:"
53 { $subsections "listener-watch" }
54 "To start a nested listener:"
55 { $subsections listener }
56 "To exit a listener, invoke the " { $link return } " word."
57 $nl
58 "Multi-line quotations can be read independently of the rest of the listener:"
59 { $subsections read-quot } ;
60
61 ABOUT: "listener"
62
63 HELP: read-quot
64 { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } }
65 { $description "Reads a Factor expression which possibly spans more than one line from " { $link input-stream } ". Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ;
66
67 HELP: listener
68 { $description "Prompts for expressions on " { $link input-stream } " and evaluates them until end of file is reached." } ;