Subject: Re: bug#49116: 28.0.50; Why `bound-and-true-p' is not working in lexical binding?

From: Michael Heerdegen <[email-masked]>
Date: Mon, 21 Jun 2021 19:00:26 +0200

Lars Ingebrigtsen <[email-masked]> writes:

> I've now copied over that text to the doc string of bound-and-true-p.

You now changed the text to this:

> Return the value of symbol VAR if it is bound, else nil.
> Note that if `lexical-binding' is in effect, this function isn't
> meaningful if it refers to a lexically bound variable.

If you want feedback: I found this new version confusing, although it's
totally correct.  Because in my mental model, `bound-and-true-p' just
receives a variable (i.e. internally quotes), so how _can_ it even
"refer" to the lexical variable at all?

But it is true:

#+begin_src emacs-lisp
(let* ((a 1)
       (get-a (lambda () (list a (bound-and-true-p a)))))
  (dlet ((a 2))
    (funcall get-a))) ;; -> (1 1), not (1 2) as one might expect
#+end_src

Everything became clear when I looked at the implementation ;-)

Maybe we can further improve the text to something like "not meaningful
in the scope of a lexical binding of the variable" or something like
that?

Thanks,

Michael.