Subject: Re: Q: optional arguments default values: evaluated when? From: Erik Naggum <firstname.lastname@example.org> Date: 1999/11/08 Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Matthew Economou <firstname.lastname@example.org> your subject question is precise enough for an answer, so the complex and possibly confusing example has been elided. the default value of an optional argument is evaluated in the lexical scope of any previously specified arguments, and any free variables are referenced as per the usual rules: ((lambda (foo &optional (bar foo) (zot bar)) (list foo bar zot)) t) ==> (t t t) or, quoting from the standard: 188.8.131.52 Specifiers for optional parameters If &optional is present, the optional parameter specifiers are those following &optional up to the next lambda list keyword or the end of the list. If optional parameters are specified, then each one is processed as follows. If any unprocessed arguments remain, then the parameter variable var is bound to the next remaining argument, just as for a required parameter. If no arguments remain, however, then init-form is evaluated, and the parameter variable is bound to the resulting value (or to nil if no init-form appears in the parameter specifier). If another variable name supplied-p-parameter appears in the specifier, it is bound to true if an argument had been available, and to false if no argument remained (and therefore init-form had to be evaluated). Supplied-p-parameter is bound not to an argument but to a value indicating whether or not an argument had been supplied for the corresponding var. #:Erik -- Attention Microsoft Shoppers! MS Monopoly Money 6.0 are now worthless.