-;;; EVAL-WHEN magic properly): Delegate to the byte compiler.
-(defun sb!bytecode:internal-eval (expr)
- (funcall (compile (gensym "EVAL-TMPFUN-")
- `(lambda ()
-
- ;; SPEED=0,DEBUG=1 => byte-compile
- (declare (optimize (speed 0) (debug 1)))
-
- ;; Other than that, basically we care about
- ;; compilation speed, compilation speed, and
- ;; compilation speed. (There are cases where
- ;; the user wants something else, but we don't
- ;; know enough to guess that; and if he is
- ;; unhappy about our guessed emphasis, he
- ;; should explicitly compile his code, with
- ;; explicit declarations to tell us what to
- ;; emphasize.)
- (declare (optimize (space 1) (safety 1)))
- (declare (optimize (compilation-speed 3)))
-
- ,expr))))
+;;; EVAL-WHEN magic properly): Delegate to #'COMPILE.
+(defun %eval (expr lexenv)
+ (funcall (sb!c:compile-in-lexenv
+ (gensym "EVAL-TMPFUN-")
+ `(lambda ()
+
+ ;; The user can reasonably expect that the
+ ;; interpreter will be safe.
+ (declare (optimize (safety 3)))
+
+ ;; It's also good if the interpreter doesn't
+ ;; spend too long thinking about each input
+ ;; form, since if the user'd wanted the
+ ;; tradeoff to favor quality of compiled code
+ ;; over compilation speed, he'd've explicitly
+ ;; asked for compilation.
+ (declare (optimize (compilation-speed 2)))
+
+ ;; Other properties are relatively unimportant.
+ (declare (optimize (speed 1) (debug 1) (space 1)))
+
+ ,expr)
+ lexenv)))
+
+;;; Handle PROGN and implicit PROGN.
+(defun eval-progn-body (progn-body lexenv)
+ (unless (list-with-length-p progn-body)
+ (let ((*print-circle* t))
+ (error 'simple-program-error
+ :format-control
+ "~@<not a proper list in PROGN or implicit PROGN: ~2I~_~S~:>"
+ :format-arguments (list progn-body))))
+ ;; Note:
+ ;; * We can't just use (MAP NIL #'EVAL PROGN-BODY) here, because we
+ ;; need to take care to return all the values of the final EVAL.
+ ;; * It's left as an exercise to the reader to verify that this
+ ;; gives the right result when PROGN-BODY is NIL, because
+ ;; (FIRST NIL) = (REST NIL) = NIL.
+ (do* ((i progn-body rest-i)
+ (rest-i (rest i) (rest i)))
+ (nil)
+ (if rest-i ; if not last element of list
+ (eval-in-lexenv (first i) lexenv)
+ (return (eval-in-lexenv (first i) lexenv)))))