關鍵字引數

可以使用 &KEY 關鍵字定義關鍵字引數。它們始終是可選的(有關定義的詳細資訊,請參閱可選引數示例)。可能有多個關鍵字引數。

(defun foobar (x y &key (z "Default" zp))
  (format t "X (~s) and Y (~s) are required.~@
             Z (~s) is a keyword argument. It ~:[wasn't~;was~] given.~%"
          x y z zp))

(foobar 10 20)
; X (10) and Y (20) are required.
; Z ("Default") is a keyword argument. It wasn't given.
;=> NIL
(foobar 10 20 :z 30)
; X (10) and Y (20) are required.
; Z (30) is a keyword argument. It was given.
;=> NIL