On Tue, Mar 3, 2020 at 8:19 AM Lassi Kortela <xxxxxx@lassi.io> wrote:

The good thing about the above `let` technique is that the `let` is
inside the procedure. Whatever you do in R7RS-large, please do _not_
make the CL mistake of allowing the default value to be specified as an
expression embedded in the lambda list itself. That is just awful :) You
can't tell what scope it's evaluated in (well, I could always go back
and read the fine print in CLHS for the umpteenth time, then forget it
again in a month).

There's a classic bug in Python programming where a function takes a list argument and mutates the argument in some way.  The programmer observes that [] is the most common value (empty lists are mutable in Python and [] is a constructor), so they set [] as the default.

Unfortunately, when the default is taken and the function mutates the list, that mutated list becomes the default for the next call!  The safe strategy is to set the default to None (which is a unique object) and then include "if arg == None: arg = []" at the top of the function.  At the moment, #f is Scheme's None.



John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
Assent may be registered by a signature, a handshake, or a click of a computer
mouse transmitted across the invisible ether of the Internet. Formality
is not a requisite; any sign, symbol or action, or even willful inaction,
as long as it is unequivocally referable to the promise, may create a contract.
       --Specht v. Netscape