Subject: Re: bug#54399: 27.2; Problems with (let ((custom-variable ...)) (autoload-function ...))

From: Ignacio Casso <[email-masked]>
Date: Tue, 12 Apr 2022 17:27:04 +0200

Stefan Monnier <[email-masked]> writes:

>>>>> ;; default defined, buffer-local undefined
>>>>> (defvar var1 "default")
>>>>> (let ((var1 "inside let")) (default-value 'var1)) ;; returns "inside let"
>>>>> 
>>>>> ;; default defined, buffer-local defined
>>>>> (defvar var2 "default")
>>>>> (setq-local var2 "buffer-local")
>>>>> (let ((var2 "inside let")) (default-value 'var2)) ;; returns "default"
>>>>
>>>> I would expect both snippets to return the same.
>>>
>>> That's because you expect the "default" in `default-value` refers to the
>>> let-nesting dimension rather than the buffer dimension.
>>
>> No, I just expect to refer to any of those consistently, I don't mind
>> which one. If it's the buffer dimension, even inside let bindings, both
>> forms should return "default".
>
> If there's no buffer-local value and `default-value` operates in the
> buffer-local dimension, why do you expect it to return a different value
> from `symbol-value`?
>
>
>         Stefan

Probably because I don't really understand all the concepts involved
here. But I expect functions that operate on the default value of the
buffer-local dimension to behave the same way regardless of whether the
current buffer happens to have actually a local value. So if
`default-value' returns something different as `symbol-value' when there
is a buffer-local value, I expect the same to occur when there is no
buffer-local value.

But never mind, I just wanted to ensure that the current behavior was
the expected one before updating the docstring for `default-boundp', and
you already confirmed that. And this is an uncommon corner case for
which I can't think of real use cases, aside from the one of autoloading
inside a let binding of a variable a file which defines that (custom)
variable, for which we are already using `default-toplevel-value' and
`set-default-toplevel-value'. So let's leave it at that.