1 ! Copyright (C) 2008 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel multiline sequences ;
8 { $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
9 { $notes { $snippet "word" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
12 "USING: kernel literals prettyprint ;"
20 "USING: kernel literals prettyprint ;"
23 ": seven-eleven ( -- a b ) 7 11 ;"
24 "{ $ seven-eleven } ."
30 { $syntax "$[ code ]" }
31 { $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
32 { $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
35 "USING: kernel literals math prettyprint ;"
38 "<< CONSTANT: five 5 >>"
39 "{ $[ five dup 1 + dup 2 + ] } ."
45 { $syntax "${ code }" }
46 { $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
47 { $notes { $snippet "code" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "${" } "." }
50 "USING: kernel literals math prettyprint ;"
60 { POSTPONE: $ POSTPONE: $[ POSTPONE: ${ } related-words
63 { $values { "values" sequence } }
64 { $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." }
67 "USING: literals kernel prettyprint ;"
70 "flags{ 0x20 x 0b100 } .h"
76 ARTICLE: "literals" "Interpolating code results into literal values"
77 "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
79 "USING: kernel literals math prettyprint ;"
82 "<< CONSTANT: five 5 >>"
83 "{ $ five $[ five dup 1 + dup 2 + ] } ."