Subject: [clisp-list] &optional and &key lambda list keywords

From: "Dave Richards" <[email-masked]>
Date: Sun Jun 2 10:06:02 2002

I thought I understood these two keywords, but it appears I do not.  Is it
true that keyword parameters assume the existence of optional arguments?
What am I missing?

test.lsp:

(defun test (a &optional b &key c)
  (list a b c))

[1]> (load "test")
;; Loading file C:\Dave\test.lsp ...
;; Loading of file C:\Dave\test.lsp is finished.
T
[2]> (test 1)
(1 NIL NIL)
[3]> (test 1 2)
(1 2 NIL)
[4]> (test 1 2 :c 3)
(1 2 3)
[5]> (test 1 :c 3)

*** - EVAL/APPLY: keyword arguments for TEST should occur pairwise
1. Break [6]>

---

From: Sam Steingold <[email-masked]>
Date: Mon Jun 3 07:30:23 2002

> * In message <[email-masked]>
> * On the subject of "&optional and &key lambda list keywords"
> * Sent on Sun, 2 Jun 2002 10:05:36 -0700
> * Honorable "Dave Richards" <[email-masked]> writes:
>
> I thought I understood these two keywords, but it appears I do not.
> Is it true that keyword parameters assume the existence of optional
> arguments?
yes.

> *** - EVAL/APPLY: keyword arguments for TEST should occur pairwise

a==1
b==:c
3 is supposed to be :c
the c argument is missing.

<http://www.lisp.org/HyperSpec/Body/sec_3-4-1-6.html>
<http://www-jcsu.jesus.cam.ac.uk/~csr21/lispfaq.html#AEN257>

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
I want Tamagochi! -- What for?  Your pet hamster is still alive!