when与if唯一的不同点在于when的代码主体可以是多句:
when的相反是unless:它接受同样的阐述,但主体仅在测试表达式返回假时,才对主体求值。
CL-USER> (when (oddp that)
(format t "Hmm,that's odd.")
(+ that 1))
Hmm,that's odd.
6
CL-USER> (if (oddp that)
(progn
(format t "Hmm,that's odd.")
(+ that 1)))
Hmm,that's odd.
6CL-USER> (setf x 4)
4
CL-USER> x
4
CL-USER> (unless (oddp x)
(format t "Hmm,x is even."))
Hmm,x is even.
NIL
CL-USER>