eval form supposed to evaluate a given form in a null lexical environment, I don't get what I expect

Viewed 582

Let's say I have a special var:

(defvar x 20)

then I do the following:

(let ((x 1)) (eval '(+ x 1))

which evaluates to 2.

According to CLHS, eval "Evaluates form in the current dynamic environment and the null lexical environment". So, I would expect to get 21 instead of 2.

Am I missing something?

Now if I have no dynamic binding for symbol y, evaluating

(let ((y 1)) (eval '(+ y 1))

I get condition: "The variable Y is unbound", which makes sense, since there is no dynamic binding for y.

Note: I'm using SBCL 1.0.57

Appreciate your help in advance!

2 Answers
Related