Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucla-cs!leo
From: leo@maui.cs.ucla.edu
Newsgroups: comp.lang.lisp
Subject: Are optional arguments required?
Keywords: CommonLISP, optional and keyword arguments.
Message-ID: <15115@shemp.CS.UCLA.EDU>
Date: 10 Aug 88 02:30:38 GMT
Sender: news@CS.UCLA.EDU
Reply-To: leo@CS.UCLA.EDU (Leonid V. Belyaev)
Distribution: na
Organization: UCLA Computer Science Department
Lines: 27

There seems to be at least one case where &optional arguments are actually
required.  Here is a simple function I was trying to define:

    (defun test-args (req1 &optional (opt1 'opt1)
			   &key (key1 'key1)
			   (key2 'key2))
      (format t "Arguments:~%~%")
      (format t "REQ1:  ~A~%" req1)
      (format t "OPT1:  ~A~%" opt1)
      (format t "KEY1:  ~A~%" key1)
      (format t "KEY2:  ~A~%" key2)
      (format t "~%")
      (values))

Seems fine so far.  Now, when you call TEST-ARGS with arguments

	1 2 :key1 3

everything is fine.  However, arguments

	1 :key1 2

result in an error.  The optional argument must be supplied before the
keyowrd arguments.  In CLtL, the examples of the mixtures of different
types of arguments never showed a case where &optional was NOT supplied and
&key was used.  It also follows the description of the argument processing
in CLtL.  However, doesn't this defeat the purpose for &optional arguments?