jdd@allegra.UUCP (John DeTreville) (06/08/84)
From: alan@allegra.UUCP (Alan S. Driscoll)
Newsgroups: net.lang.lisp
Subject: Optional Arguments in Franz Lisp
We're running Franz Lisp under 4.2 BSD. I'm having a problem
compiling functions with optional arguments. This code works
correctly when interpreted:
(defun f (&optional x &optional y) (cons x y))
When compiled, liszt gives the following error message:
?Error: test.l: f: illegal form in lambda list (&optional y)
?Error: test.l: : Compilation aborted due to previous errors
Has anyone else run into this compiler bug?
One can get around this problem by eliminating the second &optional.
From: broome@brl-tgr.ARPA (Paul Broome )
Newsgroups: net.lang.lisp
Subject: Re: Optional Arguments in Franz Lisp
Re: (defun f (&optional x &optional y) (cons x y))
Is the '&' doing something special? The function compiles
and runs correctly without the '&' under version 8.36 of Liszt
and Opus 38.79 of Franz.
"What's all this fuss about optical arguments?"
This also shows a bug in the interpreter and the compiler in that they allow
an argument to appear twice.
From: chris@umcp-cs.UUCP
Newsgroups: net.lang.lisp
Subject: Re: Optional Arguments in Franz Lisp
As I understand it [and I only dabble in Franz occasionally so don't
take this TOO seriously],
(defun f (&optional ...
makes some optional arguments, with [again optional] default values
if said optional arguments are not passed.
(defun f (&optional (x nil) (y 'foo)) ...
should make ``x'' bound to the first argument if any, nil if none,
and ``y'' bound to the second argument if any, or 'foo if none.
[It may also be written as ``(&optional x (y 'foo))''.]
As far as I know, &optional must come after all the non-optional
arguments, not be used twice, and not be used in conjunction with
&rest.
Well, almost. There is no official definition of &optional in Franz, due to
Franz's convoluted parentage. In the Lisps that it tries to copy, &optional
may be used any number of times (evidently a problem in Liszt).
Even in Franz, &optional can be used with &rest. You can also say things
like (... &optional ... (x nil x-present?) ...) to bind x-present? to
whether x gets bound to an actual argument.
Cheers,
John ("()") DeTreville
Bell Labs, Murray Hill