From: Fredrik Sandstr�m
Subject: Is this legal Common Lisp?
Date: 
Message-ID: <slrn7cuc39.li2.fredrik@infa.abo.fi>
I just noticed that the following works:
(defun f (x &optional (y x))
  ...)

That is, y gets the same value as x if not specified.  Are parameters
always bound in sequence so that this will work in all CL implementations?
(I looked in the HyperSpec but couldn't find an answer.)


                Fredrik Sandstrom | "I have never let my schooling
              ·······@infa.abo.fi |  interfere with my education."
      http://infa.abo.fi/~fredrik |                   - Mark Twain
From: Kent M Pitman
Subject: Re: Is this legal Common Lisp?
Date: 
Message-ID: <sfwzp68u13l.fsf@world.std.com>
·······@infa.abo.fi (Fredrik Sandstr�m) writes:

> I just noticed that the following works:
> (defun f (x &optional (y x))
>   ...)
> 
> That is, y gets the same value as x if not specified.  Are parameters
> always bound in sequence so that this will work in all CL implementations?
> (I looked in the HyperSpec but couldn't find an answer.)

There's a whole section on 3.4.1 on Lambda Lists.  Among the things in
3.4.1 is this:

 An init-form can be any form. Whenever any init-form is evaluated for
 any parameter specifier, that form may refer to any parameter variable
 to the left of the specifier in which the init-form appears, including
 any supplied-p-parameter variables, and may rely on the fact that no
 other parameter variable has yet been bound (including its own
 parameter variable).