unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5371: Priority of different kind of local variable bindings
@ 2010-01-13  9:20 Lennart Borgman
  2010-01-13 14:41 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2010-01-13  9:20 UTC (permalink / raw)
  To: emacs-pretest-bug

I can't find a description in the manual of the priority of different
kind of local variables. Can that please be added to the manual?






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5371: Priority of different kind of local variable bindings
  2010-01-13  9:20 bug#5371: Priority of different kind of local variable bindings Lennart Borgman
@ 2010-01-13 14:41 ` Stefan Monnier
  2010-01-13 15:50   ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2010-01-13 14:41 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: 5371

> I can't find a description in the manual of the priority of different
> kind of local variables.  Can that please be added to the manual?

What do you mean by "priority of different kind of local variables"?


        Stefan







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5371: Priority of different kind of local variable bindings
  2010-01-13 14:41 ` Stefan Monnier
@ 2010-01-13 15:50   ` Lennart Borgman
  2010-01-13 18:45     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2010-01-13 15:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 5371

On Wed, Jan 13, 2010 at 3:41 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> I can't find a description in the manual of the priority of different
>> kind of local variables.  Can that please be added to the manual?
>
> What do you mean by "priority of different kind of local variables"?


I just meant which value is active at a certain point.

I saw a strange thing working with mumamo and the js.el problem, but I
have not understod yet. I have kind of solved it, but I don't know
why. Here is some code that perhaps is related. Look at the value at
"ff". Is not that a bit surprising?

(defun temp-var-display (where)
  (message "%s temp-var: u=%s, b=%s d=%s" where
           temp-var
           (buffer-local-value 'temp-var (current-buffer))
           (default-value 'temp-var)))

(defvar temp-var "global")

(set (make-local-variable 'temp-var) "buffer-1")
(temp-var-display "bb")

(with-temp-buffer
  (set (make-local-variable 'temp-var) "buffer-2")
  (temp-var-display "cc")

  (let ((temp-var "let"))
    (temp-var-display "dd")

    (kill-local-variable 'temp-var)
    (temp-var-display "ff"))

  (temp-var-display "gg"))

(temp-var-display "hh")

(kill-local-variable 'temp-var)
(temp-var-display "ii")

bb temp-var: u=buffer-1, b=buffer-1 d=global
cc temp-var: u=buffer-2, b=buffer-2 d=global
dd temp-var: u=let, b=let d=global
ff temp-var: u=global, b=global d=global
gg temp-var: u=global, b=global d=global
hh temp-var: u=buffer-1, b=buffer-1 d=global
ii temp-var: u=global, b=global d=global






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5371: Priority of different kind of local variable bindings
  2010-01-13 15:50   ` Lennart Borgman
@ 2010-01-13 18:45     ` Stefan Monnier
  2010-01-13 18:50       ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2010-01-13 18:45 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: 5371

>> What do you mean by "priority of different kind of local variables"?
> I just meant which value is active at a certain point.

It's not based on priorities.

> (with-temp-buffer
>   (set (make-local-variable 'temp-var) "buffer-2")
>   (temp-var-display "cc")

>   (let ((temp-var "let"))
>     (temp-var-display "dd")

>     (kill-local-variable 'temp-var)
>     (temp-var-display "ff"))

The `let' binding affects the currently "active" slot, so in this case
it affects the buffer-local slot.  So after kill-local-variable, this
binding is lost.

Note that mixing let-binding and buffer-local bindings is generally
discouraged.  The only known reasonably sane semantics for such a mix is
when the variable is always buffer-local.  If you mix `let' with
make-local-variable and kill-local-variable you're really asking
for trouble.


        Stefan






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5371: Priority of different kind of local variable bindings
  2010-01-13 18:45     ` Stefan Monnier
@ 2010-01-13 18:50       ` Lennart Borgman
  0 siblings, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2010-01-13 18:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 5371

On Wed, Jan 13, 2010 at 7:45 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>> What do you mean by "priority of different kind of local variables"?
>> I just meant which value is active at a certain point.
>
> It's not based on priorities.
>
>> (with-temp-buffer
>>   (set (make-local-variable 'temp-var) "buffer-2")
>>   (temp-var-display "cc")
>
>>   (let ((temp-var "let"))
>>     (temp-var-display "dd")
>
>>     (kill-local-variable 'temp-var)
>>     (temp-var-display "ff"))
>
> The `let' binding affects the currently "active" slot, so in this case
> it affects the buffer-local slot.  So after kill-local-variable, this
> binding is lost.


Ok, I see.


> Note that mixing let-binding and buffer-local bindings is generally
> discouraged.  The only known reasonably sane semantics for such a mix is
> when the variable is always buffer-local.  If you mix `let' with
> make-local-variable and kill-local-variable you're really asking
> for trouble.


I know ;-)

Is this explained somewhere (except for the code)?






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-01-13 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13  9:20 bug#5371: Priority of different kind of local variable bindings Lennart Borgman
2010-01-13 14:41 ` Stefan Monnier
2010-01-13 15:50   ` Lennart Borgman
2010-01-13 18:45     ` Stefan Monnier
2010-01-13 18:50       ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).