added OTHERWISE support to (CASE ...)
authorAndrea Griffini <agriff@tin.it>
Wed, 1 May 2013 20:26:03 +0000 (22:26 +0200)
committerAndrea Griffini <agriff@tin.it>
Wed, 1 May 2013 20:26:03 +0000 (22:26 +0200)
src/boot.lisp
src/toplevel.lisp
tests/conditionals.lisp

index 1f8db01..d3dc898 100644 (file)
     `(let ((,!form ,form))
        (cond
          ,@(mapcar (lambda (clausule)
-                     (if (eq (car clausule) t)
-                         clausule
+                     (if (or (eq (car clausule) t)
+                             (eq (car clausule) 'otherwise))
+                         `(t ,@(cdr clausule))
                          `((eql ,!form ',(car clausule))
                            ,@(cdr clausule))))
                    clausules)))))
index c3020c0..c32dfbb 100644 (file)
@@ -66,7 +66,7 @@
           list* list-all-packages listp loop make-array make-package
           make-symbol mapcar member minusp mod multiple-value-bind
           multiple-value-call multiple-value-list multiple-value-prog1
-          nconc nil not nreconc nth nthcdr null numberp or
+          nconc nil not nreconc nth nthcdr null numberp or otherwise
           package-name package-use-list packagep parse-integer plusp pop
           prin1-to-string print proclaim prog1 prog2 progn psetq push
           quote read-from-string remove remove-if remove-if-not return
index 19736e1..af71104 100644 (file)
 (test (=   2   (cond (1 2))))
 (test (=   3   (cond (nil 1) (2 3))))
 (test (eql nil (cond (nil 1) (nil 2))))
+
+; CASE
+
+(test (= (case 1 (2 3) (otherwise 42)) 42))
+(test (= (case 1 (2 3) (t 42)) 42))
+(test (= (case 1 (2 3) (1 42)) 42))
+(test (null (case 1 (2 3))))