literals: fix formatting and example error in docs
parent
051a2a749b
commit
f5c556a709
|
@ -8,23 +8,22 @@ HELP: $
|
||||||
{ $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
|
{ $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
|
||||||
{ $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 "$" } "." }
|
{ $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 "$" } "." }
|
||||||
{ $examples
|
{ $examples
|
||||||
|
{ $example
|
||||||
{ $example """
|
"USING: kernel literals prettyprint ;"
|
||||||
USING: kernel literals prettyprint ;
|
"IN: scratchpad"
|
||||||
IN: scratchpad
|
""
|
||||||
|
"CONSTANT: five 5"
|
||||||
CONSTANT: five 5
|
"{ $ five } ."
|
||||||
{ $ five } .
|
"{ 5 }"
|
||||||
""" "{ 5 }" }
|
}
|
||||||
|
{ $example
|
||||||
{ $example """
|
"USING: kernel literals prettyprint ;"
|
||||||
USING: kernel literals prettyprint ;
|
"IN: scratchpad"
|
||||||
IN: scratchpad
|
""
|
||||||
|
": seven-eleven ( -- a b ) 7 11 ;"
|
||||||
: seven-eleven ( -- a b ) 7 11 ;
|
"{ $ seven-eleven } ."
|
||||||
{ $ seven-eleven } .
|
"{ 7 11 }"
|
||||||
""" "{ 7 11 }" }
|
}
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: $[
|
HELP: $[
|
||||||
|
@ -32,15 +31,14 @@ HELP: $[
|
||||||
{ $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
|
{ $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
|
||||||
{ $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
|
{ $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
|
||||||
{ $examples
|
{ $examples
|
||||||
|
{ $example
|
||||||
{ $example """
|
"USING: kernel literals math prettyprint ;"
|
||||||
USING: kernel literals math prettyprint ;
|
"IN: scratchpad"
|
||||||
IN: scratchpad
|
""
|
||||||
|
"<< CONSTANT: five 5 >>"
|
||||||
<< CONSTANT: five 5 >>
|
"{ $[ five dup 1 + dup 2 + ] } ."
|
||||||
{ $[ five dup 1 + dup 2 + ] } .
|
"{ 5 6 8 }"
|
||||||
""" "{ 5 6 8 }" }
|
}
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: ${
|
HELP: ${
|
||||||
|
@ -48,15 +46,14 @@ HELP: ${
|
||||||
{ $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
|
{ $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
|
||||||
{ $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 "$" } "." }
|
{ $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 "$" } "." }
|
||||||
{ $examples
|
{ $examples
|
||||||
|
{ $example
|
||||||
{ $example """
|
"USING: kernel literals math prettyprint ;"
|
||||||
USING: kernel literals math prettyprint ;
|
"IN: scratchpad"
|
||||||
IN: scratchpad
|
""
|
||||||
|
"CONSTANT: five 5"
|
||||||
CONSTANT: five 5
|
"CONSTANT: six 6"
|
||||||
CONSTANT: six 6
|
"${ five six 7 } ."
|
||||||
${ five six 7 } .
|
"{ 5 6 7 }"
|
||||||
""" "{ 5 6 7 }"
|
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -66,7 +63,8 @@ HELP: flags{
|
||||||
{ $values { "values" sequence } }
|
{ $values { "values" sequence } }
|
||||||
{ $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." }
|
{ $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." }
|
||||||
{ $examples
|
{ $examples
|
||||||
{ $example "USING: literals kernel prettyprint ;"
|
{ $example
|
||||||
|
"USING: literals kernel prettyprint ;"
|
||||||
"IN: scratchpad"
|
"IN: scratchpad"
|
||||||
"CONSTANT: x HEX: 1"
|
"CONSTANT: x HEX: 1"
|
||||||
"flags{ HEX: 20 x BIN: 100 } .h"
|
"flags{ HEX: 20 x BIN: 100 } .h"
|
||||||
|
@ -77,13 +75,14 @@ HELP: flags{
|
||||||
|
|
||||||
ARTICLE: "literals" "Interpolating code results into literal values"
|
ARTICLE: "literals" "Interpolating code results into literal values"
|
||||||
"The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
|
"The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
|
||||||
{ $example """
|
{ $example
|
||||||
USE: literals
|
"USING: kernel literals math prettyprint ;"
|
||||||
IN: scratchpad
|
"IN: scratchpad"
|
||||||
|
""
|
||||||
CONSTANT: five 5
|
"<< CONSTANT: five 5 >>"
|
||||||
{ $ five $[ five dup 1 + dup 2 + ] } .
|
"{ $ five $[ five dup 1 + dup 2 + ] } ."
|
||||||
""" "{ 5 5 6 8 }" }
|
"{ 5 5 6 8 }"
|
||||||
|
}
|
||||||
{ $subsections
|
{ $subsections
|
||||||
POSTPONE: $
|
POSTPONE: $
|
||||||
POSTPONE: $[
|
POSTPONE: $[
|
||||||
|
|
Loading…
Reference in New Issue