Next: srfi specialize-procedures design, Previous: srfi specialize-procedures rationale, Up: srfi specialize-procedures [Index]
The formal syntax of a specialized expression, in the style of the Revised^5 Report on the Algorithmic Language Scheme:
<cut-expression> --> (cut <slot-or-expr> <slot-or-expr>*) | (cut <slot-or-expr> <slot-or-expr>* <...>) | (cute <slot-or-expr> <slot-or-expr>*) | (cute <slot-or-expr> <slot-or-expr>* <...>) <slot-or-expr> --> <> ; a "slot" | <expression> ; a "non-slot expression"
The macro cut
transforms a <cut-expression>
into a
<lambda expression>
with as many formal variables as there are
slots in the list <slot-or-expr>*
. The body of the resulting
<lambda expression>
calls the first <slot-or-expr>
with
arguments from <slot-or-expr>*
in the order they appear.
In case there is a rest–slot symbol, the resulting procedure is also of
variable arity, and the body calls the first <slot-or-expr>
with
all arguments provided to the actual call of the specialized procedure.
The macro cute
is similar to the macro cut
, except that it
first binds new variables to the result of evaluating the non–slot
expressions (in an unspecific order) and then substituting the variables
for the non–slot expressions. In effect, cut
evaluates
non–slot expressions at the time the resulting procedure is called,
whereas cute
evaluates the non–slot expressions at the time the
procedure is constructed.