[Top][All Lists]

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

Re: Rant - Elisp terminology is deceptive

From: David Kastrup
Subject: Re: Rant - Elisp terminology is deceptive
Date: Sat, 24 Jan 2015 12:03:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Kelly Dean <address@hidden> writes:

> Stephen J. Turnbull wrote:
>> Buffer-local values are global values in the usual
>> sense that they are instance-wide and can be accessed in local context
>> if not shadowed by let-bindings and the like.
> Function parameters (or a closure's parameters and environment
> variables) are global variables in the sense that they're
> ‟instance-wide” (within the entire function or closure) and can be
> accessed in local context if not shadowed by let-bindings.
> But «within an entire function or closure» isn't really instance-wide?
> Well neither is «within an entire buffer».

We are not talking about "within an entire buffer".  Emacs has a notion
of a "current buffer".  There is no hierarchy or stack or nesting
involved: the current buffer setting swaps out variables in global
scope.  It does not matter which module or buffer or context your global
variables have been defined in.

> The global environment is the outermost one. A buffer's environment is
> not.

That confusion seems to be the most compelling reason _not_ to mess with
the terminology in order not to cause additional confusion.  A buffer
does not have an "environment".  It has a list of global variable values
to substitute whenever it is made current.  There is always exactly one
current buffer.  You cannot _not_ have a current buffer:

emacs -Q --batch --eval '(message "%S" (current-buffer))'
#<buffer *scratch*>

> There's only one global environment. There can be multiple buffers and
> multiple closures, each with its own environment. ‟Buffer-local” is a
> perfectly good term for buffer-locals. Calling them ‟global” would be
> misleading, and it's good that Emacs doesn't do that.
> ‟Global” is the right term for globals.

And buffer-local variables _are_ buffer-local versions of _global_
variables.  They are not scoped.  With setq-default you are not setting
a value that is in any manner more or less global than a buffer-local
setting.  It is a separate symbol slot only accessible via special
commands or when no buffer-local setting exists.

David Kastrup

reply via email to

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