[net.lang.lisp] Optional Arguments in Franz Lisp

alan@allegra.UUCP (06/07/84)

[Warning: Don't read this line.]

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?
-- 

	Alan S. Driscoll
	AT&T Bell Laboratories

broome@brl-tgr.UUCP (06/07/84)

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.

Paul Broome
broome@brl-tgr

barmar@mit-eddie.UUCP (Barry Margolin) (06/08/84)

--------------------
(defun f (&optional x &optional y) (cons x y))
--------------------

I don't know Franz Lisp, but in Maclisp and Zetalisp, everything
following &optional is optional, which means the second &optional is
redundant, and this is probably the cause for the error.
-- 
			Barry Margolin
			ARPA: barmar@MIT-Multics
			UUCP: ..!genrad!mit-eddie!barmar

chris@umcp-cs.UUCP (06/08/84)

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.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland