- (opt-lambda opt-formals body)syntax
Syntax: Opt-formals is either of the form (variable1 … variablen binding1 … bindingm) or (variable1 … variablen binding1 … bindingm . variable), where each bindingi has the form (variablen + i init), where each init is an expression. It is a syntax violation if the same variable appears more than once among the variables.
Semantics: An opt-lambda expression evaluates to a procedure and is lexically scoped in the same manner as a procedure resulting from a lambda expression. When the procedure is later called with actual arguments, the variables are bound to fresh locations, the values of the corresponding arguments are stored in those locations, the body is evaluated in the extended environment, and the results of body are returned as the results of the procedure call.
A procedure created with the first syntax of opt-formals takes at least n arguments and at most n + m arguments. A procedure created with the second syntax of opt-formals takes n or more arguments. If the procedure is called with fewer than n + m (but at least n arguments), the missing actual arguments are substituted by the values resulting from evaluating the corresponding inits. The corresponding inits are evaluated in an unspecified order in the lexical environment of the opt-lambda expression when the procedure is called.
It is an assertion violation if the procedure created with the first syntax of opt-formals is called with more than n + m actual arguments. The value stored in the binding of variable of a procedure created with the second syntax of opt-formals will be a newly allocated list of the actual arguments left over after all the other actual arguments have been matched up against the other formal arguments (or the empty list in case no actual arguments are left over).
Note: Both n and m may be zero.