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 "$" } "." }
13 USING: kernel literals prettyprint ;
21 USING: kernel literals prettyprint ;
24 : seven-eleven ( -- a b ) 7 11 ;
31 { $syntax "$[ code ]" }
32 { $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
33 { $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
37 USING: kernel literals math prettyprint ;
40 << CONSTANT: five 5 >>
41 { $[ five dup 1 + dup 2 + ] } .
47 { $syntax "${ code }" }
48 { $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
49 { $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 "$" } "." }
53 USING: kernel literals math prettyprint ;
63 { POSTPONE: $ POSTPONE: $[ POSTPONE: ${ } related-words
66 { $values { "values" sequence } }
67 { $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." }
69 { $example "USING: literals kernel prettyprint ;"
72 "flags{ HEX: 20 x BIN: 100 } .h"
78 ARTICLE: "literals" "Interpolating code results into literal values"
79 "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
85 { $ five $[ five dup 1 + dup 2 + ] } .