Fried quotations
Factor handbook > The language

Prev:Global variables

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).

Fried quotations can also be constructed without using a parsing word; this is useful when meta-programming:
fry ( quot -- 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.