unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* crazy interaction between buffer-locality and function-locality of variables
@ 2008-11-02  3:34 Ami Fischman
  2008-11-02 16:57 ` Stefan Monnier
  2008-11-02 23:19 ` crazy interaction between buffer-locality and function-locality of variables Richard M. Stallman
  0 siblings, 2 replies; 7+ messages in thread
From: Ami Fischman @ 2008-11-02  3:34 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1516 bytes --]

This snippet:

(make-local-variable 'ami-wcb-bug-foo)
(defun ami-wcb-bug (ami-wcb-bug-foo)
  (with-temp-buffer
    ami-wcb-bug-foo))
(ami-wcb-bug 'bar)

eval'd in a *scratch* buffer results in this error: (void-variable
ami-wcb-bug-foo)
because ami-wcb-bug-foo is not bound in the temporary buffer, because the
same name has been declared local in *scratch*, and the function-call
binding happens in that buffer.  A similar situation for let-binding is
described in elisp.info's "11.10.1 Introduction to Buffer-Local Variables".
This happens in 22.1.1 and in CVS HEAD.

Is the behavior of binding function arguments variables subject to the
locality of the current buffer at function call time intentional?  It makes
writing functions that respond to asynchronous events require using local
variables with names that are globally unique (prefixed with package name,
presumably), which is a PITA.  An example of where this bit me: gnus makes
'timestamp buffer-local in *Summary* buffers, and emacs-jabber has a
function that uses "timestamp" as the name of one of its arguments and then
calls with-temp-buffer inside that function.  So most of the time receiving
jabber messages works just fine, but if the user happens to have point in a
*Summary* buffer then message reciept triggers a void-variable error.

It seems to me that this behavior is broken, but if it's to be kept there
needs to be strong guidance against making variables whose names /aren't/
prefixed with the package name buffer-local.

Cheers,
-Ami

[-- Attachment #2: Type: text/html, Size: 1699 bytes --]

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

end of thread, other threads:[~2008-11-02 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-02  3:34 crazy interaction between buffer-locality and function-locality of variables Ami Fischman
2008-11-02 16:57 ` Stefan Monnier
2008-11-02 17:43   ` Ami Fischman
2008-11-02 20:05     ` Stefan Monnier
2008-11-02 20:31       ` crazy interaction between buffer-locality and function-localityof variables Drew Adams
2008-11-02 23:19 ` crazy interaction between buffer-locality and function-locality of variables Richard M. Stallman
2008-11-02 23:59   ` Ami Fischman

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).