scope - Common Lisp the Language: "dynamic shadowing cannot occur" -
near end of chapter 3 of common lisp language, steele writes "constructs use lexical scope generate new name each established entity on each execution. therefore dynamic shadowing cannot occur (though lexical shadowing may)". confused means "dynamic shadowing cannot occur". example of "dynamic shadowing" like?
here example of might have meant:
(defun f (g) (let ((a 2)) (funcall g a))) (let ((a 1)) (f (lambda (x) (- x a))))
this returns 1
in common lisp because lexical binding of a
in f
not affect binding of a
in top-level let
, so, when f
calls g
, subtracts 1
2
because lambda
gets a
top-level binding.
contrast dynamic binding in emacs lisp, return value 0
.
you might find instructive work out contorted-example
, try in cl , elisp.
Comments
Post a Comment