纠正:
- Common Lisp 是 lexical 和 dynamic 混合的,默认 lexical,用 DEFPARAMETER 或 DEFVAR 在顶层定义的是变量是 dynamic 的。开了 lexical 的 Emacs Lisp 和 CL 一样。
[1]> (defparameter foo 1)
FOO
[2]> (defun x (y) (+ y foo))
X
[3]> (x 4)
5
[4]> (let ((foo 3)) (x 4))
7
- Lisp Machine Lisp 支持 lexical binding,并且在后期版本(ZetaLisp)中默认使用 lexical binding。(实际上它和 CL 并没有太多区别)
另外推薦 RMS 在去搞 GNU 之前写的 Lisp Machine Manual 中对 Closure 的讲解。
https://hanshuebner.github.io/lmman/fd-clo.xml#What%20a%20Closure%20Is-section