|
From: | Andreas Röhler |
Subject: | Re: Declaring a local dynamic variable? |
Date: | Sun, 13 Oct 2013 10:12:42 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
Am 12.10.2013 23:25, schrieb Kai Grossjohann:
On Saturday, October 12, 2013 6:54:40 PM UTC+2, Andreas Röhler wrote:Am 25.09.2013 14:26, schrieb Stefan Monnier:So in essence Emacs doesn't really have local dynamic variables?Dynamic scoping is inherently global,Reads like a mistake for me.I think it makes sense. In a language that has lexical scoping, you can get the effect of dynamic scoping by changing the value of a global variable. (defvar x 5) bla bla (let ((x 6)) yadda yadda) mumble mumble The above code has the same effect as - create global variable x, initialize it to 5 - execute bla bla - change value of x to 6
No. Introduces a let-bound x, which is unrelated to global x dynamical-scoped let-bound behave different than lexical-scoped let-bound vars, that's at stake. If a global var of the same name exists or not is another issue. Therefor consider it a misuse and design-flaw to use "defvar" signaling dynamic-scope in let-bound vars. "defvar" initialised a global var. Never was related to stuff inside let. At least not at the Emacs Lisp symbol-level.
- execute yadda yadda - change value of x back to 5 - execute mumble mumble But dynamically-scoped let has the advantage that it remembers the old value for you, and it catches all ways that the "yadda yadda" might exit.
[Prev in Thread] | Current Thread | [Next in Thread] |