At the moment I\'m working through \"Practical Common Lisp\" from Peter Seibel.
In the chapter \"Practical: A Simple Database\" (http://www.gigamonkeys.com/book/pract
It's difficult to tell what you are asking. c-p
is bound to T
or NIL
, depending on whether c
is supplied as a parameter. This binding is then available to the body of the function.
Let's reindent the function foo:
(defun foo (&key a
(b 20)
(c 30 c-p))
(list a b c c-p))
If you indent it like this you will see that the function has three keyword parameters: a, b and c. These are available in the body of the function.
For the keyword parameter c there is a variable declared c-p that will be T or NIL depending whether c has been passed when foo gets called.
A keyword parameter generally can be declared as one of the following options:
The supplied-p is particularly interesting when one wants to see whether the value comes from the call or the default value:
(defun make-my-array (size &key (init-value nil init-value-supplied-p))
(if init-value-supplied-p
(make-array size :initial-element init-value)
(make-array size)))
Now the user can init the elements to NIL:
(make-my-array 10 :init-value nil)
Here the default value and the supplied value can both be NIL, but we need to make a difference. The variable init-value-supplied-p makes it possible to see whether the NIL value of the variable init-value comes from the default or from the function call.