[Top][All Lists]

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

bug#10604: 23.2; variable lookup: make-local-variable interaction with w

From: Stefan Monnier
Subject: bug#10604: 23.2; variable lookup: make-local-variable interaction with with-temp-buffer
Date: Wed, 25 Jan 2012 21:11:54 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

tags 10604 wontfix

> Switch to *scratch*, and do the following:
> (defun func (my-var)
>   (with-temp-buffer
>     (message my-var)))
> C-j

> (func "z")
> C-j
> ; no problem, works as expected
> (make-local-variable 'my-var)
> C-j
> (func "z")
> C-j
> ; ERROR with the stack trace

> Debugger entered--Lisp error: (void-variable my-var)

Yes, that's how dynamic-scoping and buffer-local bindings interact.
Another way to trigger the problem:

    (make-local-variable 'my-var)
    (let ((my-var 1))
       (message my-var)))

of course, it's the same because `let' works the same as the binding
done for function arguments.

Maybe there is a way to define the interaction of buffer-local bindings
and dynamically scoped vars in a way that doesn't suffer from this
problem, but it's probably going to suffer from other problems instead,
and it's highly unlikely to be compatible with existing code, so
you're better learning to live with it (the way to do that is to
usually avoid such interactions like the plague: either let-bind or
buffer-local but not both, tho sometimes you can't avoid combining


reply via email to

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