Node:Optional Arguments, Next:, Previous:Lambda, Up:Procedures and Macros



23.2 Optional Arguments

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 argument, but the remaining (optional) arguments can be only referenced as a list of values (see Lambda).

Guile comes with the module (ice-9 optargs), which makes using optional arguments much more convenient. In addition, this module provides syntax for handling keywords in argument lists (see Keywords).

Before using any of the procedures or macros defined in this section, you have to load the module (ice-9 optargs) with the statement:

(use-modules (ice-9 optargs))