Subject: bug#62840: 30.0.50; Doc bug: obsolete paragraph in Elisp Ref

From: Stefan Monnier <[email-masked]>
Date: Sat, 15 Apr 2023 09:11:37 -0400

>> I don't know if the structure of the lexical environment was ever really
>> relevant: it seems to be an internal detail that should not have found
>> its way into the documentation in the first place, but that's guessing
>> on my part.
>> 
>> The important thing is that it does not seem to be the case any longer:
>> the `t' is present at the end of the lexical environment in Emacs 28.2:
>> 
>>     (let ((foo 233)) (lambda (x) (* x foo))) ==> (closure ((foo . 233) t) (x) (* x foo))
>> 
>> but it is no longer present in current upstream:
>> 
>>     (let ((foo 233)) (lambda (x) (* x foo))) ==> (closure ((foo . 233)) (x) (* x foo))
>> 
>> so the above paragraph needs modification (if not outright excision).
>
> Stefan, any comments?  Should this text be amended, deleted, or
> something else?

Indeed the "with a `t` at the end" should probably not have been
documented and can be removed.  The `t` can still appear there
(sometimes it does sometimes it doesn't).  More important would be to
document that beside (SYM . VAL) pairs, the env can contain symbols,
which means that the lexical environment declared that variable as being
locally considered as a dynbind variable.

E.g. in

    (defun my-fun (baz)
      (defvar my-foo)
      (lambda (x) (let ((my-foo x)) (bar baz))))

`my-foo` will appear in the environment of the closure returned by the
function so as to remember the `defvar` since it affects the execution
of the body.

        Stefan