Fried quotations
Factor handbook ยป The language

Prev:Global variables
Next:Objects


The fry vocabulary implements fried quotation. Conceptually, fried quotations are quotations with "holes" (more formally, fry specifiers), and the holes are filled in when the fried quotation is pushed on the stack.

Fried quotations are started by a special parsing word:
'[


There are two types of fry specifiers; the first can hold a value, and the second "splices" a quotation, as if it were inserted without surrounding brackets:
_ ( -- * )

@ ( -- * )


The holes are filled in with the top of stack going in the rightmost hole, the second item on the stack going in the second hole from the right, and so on.
Examples of fried quotations
Fried quotation philosophy

Fry is implemented as a parsing word which reads a quotation and scans for occurrences of _ and @; these words are not actually executed, and doing so raises an error (this can happen if they're accidentally used outside of a fry).

Printed definitions preserve the fry syntax. The single-step walker treats filling the holes as one step. Its Into command also inserts a breakpoint at the beginning of the resulting quotation, so execution pauses inside its body when it is called.

Fried quotations can also be constructed without using a parsing word; this is useful when meta-programming:
fry ( object -- quot )


Fried quotations are an abstraction on top of the Compositional combinators; their use is encouraged over the combinators, because often the fry form is shorter and clearer than the combinator form.