1 ! Copyright (C) 2008 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel multiline ;
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
65 ARTICLE: "literals" "Interpolating code results into literal values"
66 "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
72 { $ five $[ five dup 1 + dup 2 + ] } .
74 { $subsection POSTPONE: $ }
75 { $subsection POSTPONE: $[ }
76 { $subsection POSTPONE: ${ }