Scheme procedures, as defined in R5RS, can either handle a fixed number of actual arguments, or a fixed number of actual arguments followed by arbitrarily many additional arguments. Writing procedures of variable arity can be useful, but unfortunately, the syntactic means for handling argument lists of varying length is a bit inconvenient. It is possible to give names to the fixed number of arguments, but the remaining (optional) arguments can be only referenced as a list of values (see Lambda).
For this reason, Guile provides an extension to
lambda*, which allows the user to define procedures with
optional and keyword arguments. In addition, Guile’s virtual machine
has low-level support for optional and keyword argument dispatch.
Calls to procedures with optional and keyword arguments can be made
cheaply, without allocating a rest list.
|• lambda* and define*||Creating advanced argument handling procedures.|
|• ice-9 optargs||(ice-9 optargs) provides some utilities.|