0.9.11.36: add support for IF in EVAL-IN-LEXENV
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 14 Apr 2006 08:58:15 +0000 (08:58 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 14 Apr 2006 08:58:15 +0000 (08:58 +0000)
 I wonder why this wasn't here before?

NEWS
src/code/eval.lisp
tests/eval.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index cc670d7..7800e5a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,8 @@ changes in sbcl-0.9.12 relative to sbcl-0.9.11:
   * minor incompatible change: Error signalling behaviour of lexical
     operations violating package locks has changed slightly. Refer to
     documentation on package locks for details.
+  * enhancement: EVAL can process IF-expressions without resorting to the
+    compiler.
   * bug fix: LISTEN sometimes returned T even in cases where no data was
     immediately available from the stream
   * fixed bug: types of the last two arguments to SET-SYNTAX-FROM-CHAR
index 8e67686..f09a9c3 100644 (file)
                            (values sb!c:*lexenv* vars))
                          :eval))
                     (eval-locally `(locally ,@body) lexenv :vars vars))))
+               ((if)
+                (destructuring-bind (test then &optional else) (rest exp)
+                  (eval-in-lexenv (if (eval-in-lexenv test lexenv)
+                                      then
+                                      else)
+                                  lexenv)))
                (t
                 (if (and (symbolp name)
                          (eq (info :function :kind name) :function))
index da75fb0..5989e51 100644 (file)
                (with-output-to-string (*standard-output*)
                  (eval '(progn (princ ".") (let ((x 42)) t) (princ "."))))))
 
+;;; IF
+(defun true () t)
+(defun false () nil)
+(defmacro oops () (throw :oops (list)))
+(defun test-eval (ok form) (assert (eq ok (catch :oops (eval form)))))
+(test-eval t '(if (false) (oops) t))
+(test-eval t '(if (true) t (oops)))
+(test-eval nil '(if (not (if (false) t)) (oops)))
+
 ;;; success
index a9faa11..7b72fce 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".)
-"0.9.11.35"
+"0.9.11.36"