]> gitweb.factorcode.org Git - factor.git/blob - basis/values/values-docs.factor
Fix permission bits
[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 POSTPONE: to: }\r
11 { $subsection change-value } ;\r
12 \r
13 HELP: VALUE:\r
14 { $syntax "VALUE: word" }\r
15 { $values { "word" "a word to be created" } }\r
16 { $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
17 \r
18 HELP: get-value\r
19 { $values { "word" "a value word" } { "value" "the contents" } }\r
20 { $description "Gets a value. This should not normally be used, unless the word is not known until runtime." } ;\r
21 \r
22 HELP: set-value\r
23 { $values { "value" "a new value" } { "word" "a value word" } }\r
24 { $description "Sets a value word." } ;\r
25 \r
26 HELP: to:\r
27 { $syntax "... to: value" }\r
28 { $values { "word" "a value word" } }\r
29 { $description "Sets a value word." }\r
30 { $notes\r
31     "Note that"\r
32     { $code "foo to: value" }\r
33     "is just sugar for"\r
34     { $code "foo \\ value set-value" }\r
35 } ;\r
36 \r
37 HELP: change-value\r
38 { $values { "word" "a value word" } { "quot" "a quotation with stack effect " { $snippet "( oldvalue -- newvalue )" } } }\r
39 { $description "Changes the value using the given quotation." } ;\r