touch up quotation documentation
parent
9163e4e552
commit
2f90b13160
|
@ -3,29 +3,28 @@ vectors kernel combinators ;
|
||||||
IN: quotations
|
IN: quotations
|
||||||
|
|
||||||
ARTICLE: "quotations" "Quotations"
|
ARTICLE: "quotations" "Quotations"
|
||||||
"Conceptually, a quotation is an anonymous function (a value denoting a snippet of code) which can be passed around and called."
|
"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called. Quotations are delimited by square brackets (" { $snippet "[ ]" } "); see " { $link "syntax-quots" } " for details on their syntax."
|
||||||
$nl
|
$nl
|
||||||
"Concretely, a quotation is an immutable sequence of objects, some of which may be words, together with a block of machine code which may be executed to achieve the effect of evaluating the quotation. The machine code is generated by a fast non-optimizing quotation compiler which is always running and is transparent to the developer."
|
"Quotations form a class of objects:"
|
||||||
$nl
|
|
||||||
"Quotations form a class of objects, however in most cases, methods should dispatch on " { $link callable } " instead, so that " { $link curry } " and " { $link compose } " values can participate."
|
|
||||||
{ $subsections
|
{ $subsections
|
||||||
quotation
|
quotation
|
||||||
quotation?
|
quotation?
|
||||||
}
|
}
|
||||||
"Quotations evaluate sequentially from beginning to end. Literals are pushed on the stack and words are executed. Details can be found in " { $link "evaluator" } "."
|
"A more general class is provided for methods to dispatch on that includes quotations, " { $link curry } ", and " { $link compose } " objects:"
|
||||||
$nl
|
{ $subsections
|
||||||
"Quotation literal syntax is documented in " { $link "syntax-quots" } "."
|
callable
|
||||||
$nl
|
}
|
||||||
|
"Quotations evaluate sequentially from beginning to end. Literals are pushed on the stack and words are executed. Details can be found in " { $link "evaluator" } ". Words can be placed in wrappers to suppress execution:"
|
||||||
|
{ $subsections "wrappers" }
|
||||||
"Quotations implement the " { $link "sequence-protocol" } ", and existing sequences can be converted into quotations:"
|
"Quotations implement the " { $link "sequence-protocol" } ", and existing sequences can be converted into quotations:"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
>quotation
|
>quotation
|
||||||
1quotation
|
1quotation
|
||||||
}
|
}
|
||||||
"Wrappers:"
|
"Although quotations can be treated as sequences, the compiler will be unable to reason about quotations manipulated as sequences at runtime. " { $link "compositional-combinators" } " are provided for runtime partial application and composition of quotations." ;
|
||||||
{ $subsections "wrappers" } ;
|
|
||||||
|
|
||||||
ARTICLE: "wrappers" "Wrappers"
|
ARTICLE: "wrappers" "Wrappers"
|
||||||
"Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:"
|
"Wrappers evaluate to the object being wrapped when encountered in code. They are are used to suppress the execution of " { $link "words" } " so that they can be used as values."
|
||||||
{ $subsections
|
{ $subsections
|
||||||
wrapper
|
wrapper
|
||||||
literalize
|
literalize
|
||||||
|
|
|
@ -106,7 +106,7 @@ ARTICLE: "syntax-numbers" "Number syntax"
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
ARTICLE: "syntax-words" "Word syntax"
|
ARTICLE: "syntax-words" "Word syntax"
|
||||||
"A word occurring inside a quotation is executed when the quotation is called. Sometimes a word needs to be pushed on the data stack instead. The canonical use-case for this is passing the word to the " { $link execute } " combinator, or alternatively, reflectively accessing word properties (" { $link "word-props" } ")."
|
"A word occurring inside a quotation is executed when the quotation is called. Sometimes a word needs to be pushed on the data stack instead. The canonical use case for this is passing the word to the " { $link execute } " combinator, or alternatively, reflectively accessing word properties (" { $link "word-props" } ")."
|
||||||
{ $subsections
|
{ $subsections
|
||||||
POSTPONE: \
|
POSTPONE: \
|
||||||
POSTPONE: POSTPONE:
|
POSTPONE: POSTPONE:
|
||||||
|
|
Loading…
Reference in New Issue