This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Ticket 54: optional arguments

2011-01-24 08:13:25
WG1 - Core
2010-05-02 23:24:09

Scheme's primitive mechanism of improper lambda-lists allows for optional arguments, but only with extra machinery. CL, DSSSL, and some Schemes provide a special word such as #!optional in lambda-lists, showing that the arguments which follow are optional and may have default values. SRFI 16 (case-lambda) is an alternative method of providing for optional arguments: it allows a procedure to define multiple lambda-lists each of different lengths, with separate bodies for each. This is like method overloading, but without types.

I think it's important to have a simple approach to optional arguments. Programmers often want them, although it's difficult to count such instances because so much code just cracks the lambda-list-tail variable. Such code is often brittle, simply ignoring excess optional arguments even if the surrounding Scheme implementation reports errors on them.

The #!optional keyword requires special magic in the lambda form. Case-lambda can be provided directly by a syntax-rules macro, and therefore I prefer it.

I also prefer the CASE-LAMBDA in the standard. I think that it is easy to add in optional keyword arguments using records or the like, so I don't see a need for them to be in the standard. I'm not sure that CASE-LAMBDA is a suitable addition to WG1 though.

I am also in favor of Case-Lambda syntax provided as a macro.


The WG voted to refer optional-argument support (excluding case-lambda, which is #78) to WG2.