GNU bug report logs - #49116
28.0.50; Why `bound-and-true-p' is not working in lexical binding?

Previous Next

Package: emacs;

Reported by: Jean Louis <bugs <at> gnu.support>

Date: Sat, 19 Jun 2021 11:43:02 UTC

Severity: normal

Found in version 28.0.50

Done: Phil Sainty <psainty <at> orcon.net.nz>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, 49116 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, bugs <at> gnu.support
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
Lars Ingebrigtsen <larsi <at> 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.




This bug report was last modified 3 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.