]> gitweb.factorcode.org Git - factor.git/blob - basis/values/values-docs.factor
Create basis vocab root
[factor.git] / basis / values / values-docs.factor
1 USING: help.markup help.syntax ;\r
2 IN: values\r
3 \r
4 ARTICLE: "values" "Global values"\r
5 "Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. Values abstract over this concept. To create a new word as a value, use the following syntax:"\r
6 { $subsection POSTPONE: VALUE: }\r
7 "To get the value, just call the word. The following words manipulate values:"\r
8 { $subsection get-value }\r
9 { $subsection set-value }\r
10 { $subsection change-value } ;\r
11 \r
12 HELP: VALUE:\r
13 { $syntax "VALUE: word" }\r
14 { $values { "word" "a word to be created" } }\r
15 { $description "Creates a value on the given word, initializing it to hold " { $code f } ". To get the value, just run the word. To set it, use " { $link set-value } "." } ;\r
16 \r
17 HELP: get-value\r
18 { $values { "word" "a value word" } { "value" "the contents" } }\r
19 { $description "Gets a value. This should not normally be used, unless the word is not known until runtime." } ;\r
20 \r
21 HELP: set-value\r
22 { $values { "value" "a new value" } { "word" "a value word" } }\r
23 { $description "Sets the value word." } ;\r
24 \r
25 HELP: change-value\r
26 { $values { "word" "a value word" } { "quot" "a quotation ( oldvalue -- newvalue )" } }\r
27 { $description "Changes the value using the given quotation." } ;\r