1.0.14.26: tweak COND slightly
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Feb 2008 14:16:11 +0000 (14:16 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Feb 2008 14:16:11 +0000 (14:16 +0000)
 * Don't expand into a final (COND), but directly to NIL (easier to
   read macroexpansion.)

 * Check for the common case of final T, so that the last clause can be
   unconditional instead of generating redundant IF.

src/code/defboot.lisp
tests/walk.impure.lisp
version.lisp-expr

index bce8766..16fd031 100644 (file)
@@ -69,7 +69,8 @@
 (defmacro-mundanely cond (&rest clauses)
   (if (endp clauses)
       nil
-      (let ((clause (first clauses)))
+      (let ((clause (first clauses))
+            (more (rest clauses)))
         (if (atom clause)
             (error "COND clause is not a list: ~S" clause)
             (let ((test (first clause))
                     `(let ((,n-result ,test))
                        (if ,n-result
                            ,n-result
-                           (cond ,@(rest clauses)))))
-                  `(if ,test
-                       (progn ,@forms)
-                       (cond ,@(rest clauses)))))))))
+                           (cond ,@more))))
+                  (if (eq t test)
+                      `(progn ,@forms)
+                      `(if ,test
+                           (progn ,@forms)
+                           ,(when more `(cond ,@more))))))))))
 
 (defmacro-mundanely when (test &body forms)
   #!+sb-doc
index 9c3e44b..2045fa0 100644 (file)
@@ -933,14 +933,13 @@ Form: A   Context: EVAL
 Form: (PROGN B)   Context: EVAL
 Form: B   Context: EVAL
 Form: (COND ((FOO BAR) A (FOO A)))   Context: EVAL
-Form: (IF (FOO BAR) (PROGN A (FOO A)) (COND))   Context: EVAL
+Form: (IF (FOO BAR) (PROGN A (FOO A)) NIL)   Context: EVAL
 Form: (FOO BAR)   Context: EVAL
 Form: 'GLOBAL-FOO   Context: EVAL
 Form: (PROGN A (FOO A))   Context: EVAL
 Form: A   Context: EVAL
 Form: (FOO A)   Context: EVAL
 Form: 'GLOBAL-FOO   Context: EVAL
-Form: (COND)   Context: EVAL
 Form: NIL   Context: EVAL; bound: NIL
 (COND (A B) ((FOO BAR) A (FOO A)))"))
 
index 2b56830..3a10048 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.14.25"
+"1.0.14.26"