[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49116: 28.0.50; Why `bound-and-true-p' is not working in lexical bin
From: |
Michael Heerdegen |
Subject: |
bug#49116: 28.0.50; Why `bound-and-true-p' is not working in lexical binding? |
Date: |
Mon, 21 Jun 2021 19:00:26 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Lars Ingebrigtsen <larsi@gnus.org> 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.
bug#49116: 28.0.50; Why `bound-and-true-p' is not working in lexical binding?, Michael Heerdegen, 2021/06/22