let,eval和quote的行为

Pet*_*ang 4 lisp common-lisp

我试图了解其行为let.为什么case2会给我一个错误?

;; case1: worked fine.
(let ((NF 5)) NF)
5

;; case2: got an error
(let ((NF 5)) (eval 'NF))
error: The variable NF is unbound
Run Code Online (Sandbox Code Playgroud)

Bar*_*mar 8

EVAL无法访问词法变量.该CLHS说:

评估当前动态环境和null词法环境中的表单.

如果声明变量special它将起作用,因为它执行动态绑定而不是词法绑定.

(let ((NF 5))
  (declare (special NF))
  (eval 'NF))
5
Run Code Online (Sandbox Code Playgroud)