www.delorie.com/gnu/docs/guile/guile_255.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 section 23.1 Lambda: Basic Procedure Creation).

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 section 21.7 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))

23.2.1 let-optional Reference  Locally binding optional arguments.
23.2.2 let-keywords Reference  Locally binding keywords arguments.
23.2.3 lambda* Reference  Creating advanced argument handling procedures.
23.2.4 define* Reference  Defining procedures and macros.

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003