emacs-devel
[Top][All Lists]
Advanced

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

Re: Question reg. docstring of symbol-value


From: Tassilo Horn
Subject: Re: Question reg. docstring of symbol-value
Date: Wed, 03 Nov 2021 08:38:41 +0100
User-agent: mu4e 1.7.4; emacs 29.0.50

Robin Tarsiger <rtt@dasyatidae.com> writes:

>> Is the intention to say "..., this returns the global value outside of
>> any lexical scope for symbols not marked as special" or something like
>> that?  Or am I missing something?
>
> From the documentation for defvar:
>
>> The ‘defvar’ form also declares the variable as "special", so that it
>> is always dynamically bound even if ‘lexical-binding’ is t.
>
> Basically, special variables don't get lexically bound in the first
> place, so the let doesn't introduce a lexical binding for that
> variable; it introduces a dynamic one, and dynamic bindings affect
> symbol-value.

Right, that's what we've observed and which we consider as expected
outcome.  The only situation where we've observed a difference in just
taking the value of a global variable or using `symbol-value' on its
symbol is for globals which came into being in terms of plain `setq'
instead `defvar' (which is bad practice anyway).

Is that really the only corner case where `global-var' and
`(symbol-value 'global-var)' can differ?  If so, the docstring (and the
info manual) could be much more specific.  If not, it would make sense
to name those situations, and provide examples in the manual.

Bye,
Tassilo



reply via email to

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