help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declaring a local dynamic variable?


From: Andreas Röhler
Subject: Re: Declaring a local dynamic variable?
Date: Sun, 13 Oct 2013 19:41:46 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

Am 13.10.2013 15:37, schrieb Stefan Monnier:
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

You're confused.

Really?

So that's what I get:

(defvar x 5)
x->5

(let ((x 6))
  x)

->6 (#o6, #x6, ?\C-f)

x->5

GNU Emacs 24.3.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2013-08-28

[ ... ]

The real story is more complicated because the old value stashed on the
stack includes the information about whether `x' was already defined or
not,


Sure it's more complicated. We are taking about the use of symbols at Emacs 
Lisp level, not about internals.
BTW I'm not blaming anybody because something went wrong. Just saying: let's 
correct it.

Best,

Andreas

and more importantly because variables can be buffer-local, so it
needs also to remember which buffer's value was modified and only restore
`x' for that buffer.


         Stefan







reply via email to

[Prev in Thread] Current Thread [Next in Thread]