From 22e18896b53b0af44b1e18f885c943f6c3e50d01 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 14 Apr 2006 08:58:15 +0000 Subject: [PATCH] 0.9.11.36: add support for IF in EVAL-IN-LEXENV I wonder why this wasn't here before? --- NEWS | 2 ++ src/code/eval.lisp | 6 ++++++ tests/eval.impure.lisp | 9 +++++++++ version.lisp-expr | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index cc670d7..7800e5a 100644 --- 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 diff --git a/src/code/eval.lisp b/src/code/eval.lisp index 8e67686..f09a9c3 100644 --- a/src/code/eval.lisp +++ b/src/code/eval.lisp @@ -225,6 +225,12 @@ (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)) diff --git a/tests/eval.impure.lisp b/tests/eval.impure.lisp index da75fb0..5989e51 100644 --- a/tests/eval.impure.lisp +++ b/tests/eval.impure.lisp @@ -188,4 +188,13 @@ (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 diff --git a/version.lisp-expr b/version.lisp-expr index a9faa11..7b72fce 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4