Commit 64d0746e authored by Juergen Nickelsen's avatar Juergen Nickelsen

027-when-unless.lisp and related fix

parent f768db10
......@@ -440,15 +440,15 @@
firstval
(eval-list rest)))))
(defspecial unless (cond &rest body)
"if COND yields nil, eval &rest BODY and return the result of the last"
(defspecial unless (cond &rest bodyforms)
"if COND yields nil, eval &rest BODYFORMS and return the result of the last"
(if (not (eval cond))
(eval-list bodyforms)))
(defspecial when (cond &rest body)
"if COND yields true, eval &rest BODY and return the result of the last"
(defspecial when (cond &rest bodyforms)
"if COND yields true, eval &rest BODYFORMS and return the result of the last"
(if (eval cond)
(eval-list body)))
(eval-list bodyforms)))
(defspecial cond (&rest clauses)
(if (null clauses)
......
(defun false ()
nil)
(defun true ()
t)
(testcmp "when 0" '(when (false) (+ 13 14) (* 15 16) 332) nil)
(testcmp "when 1" '(when (true) (+ 13 14) (* 15 16) 332) 332)
(testcmp "when 2" '(let (a) (when (true) (setq a 115) 19) a) 115)
(testcmp "unless 0" '(unless (false) (+ 13 14) (* 15 16) 332) 332)
(testcmp "unless 1" '(unless (true) (+ 13 14) (* 15 16) 332) nil)
(testcmp "unless 2" '(let (a) (unless (false) (setq a 115) 19) a) 115)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment