I\'ve learned that static scoping is the only sane way to do things, and that dynamic scoping is the tool of the devil, and results only from poor implementations of interpr
Dynamic Scoping breaks Referential Transparency, which means you cannot reason about the program any more. DS is basically global variables on steroids.
This classic article by Richard Stallman (of GNU/Linux, Emacs, FSF) explains why dynamic scoping is important to the Emacs editor and the Emacs Lisp language. In sum, it is useful for customizing.
http://www.gnu.org/software/emacs/emacs-paper.html#SEC17
See also this page on the Emacs wiki, for more info about the use of dynamic scoping in Emacs Lisp:
I think dynamic scope in Common LISP is analogy of Global Variable in C. Using them in a functional functions is problematic.
An example whats convenient for me at the Emacs way of binding - not sure if lexical or dynamic is the right term BTW.
A variable bound inside a let is seen downward, no explicit hand-over as argument needed, which saves a lot of keystrokes.
(defun foo1 ()
(message "%s" a))
(defun foo2 ()
(let ((a 2))
(message "%s" a)))
(defun foo3 ()
(let ((a 1))
(foo1)
(foo2)))
==>
1
2
Binding inside foo2 is of interest, as a usage of default values might be installed here
(let ((a (if (eq something a) assign otherwise...