GNU bug report logs - #52063
28.0.60; Confusing presentation of lambda

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Tue, 23 Nov 2021 18:57:02 UTC

Severity: normal

Found in version 28.0.60

Full log


View this message in rfc822 format

From: Jim Porter <jporterbugs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, 52063 <at> debbugs.gnu.org
Subject: bug#52063: 28.0.60; Confusing presentation of lambda
Date: Wed, 24 Nov 2021 14:33:22 -0800
On 11/24/2021 12:14 PM, Eli Zaretskii wrote:
> I look at the values to make sure they are what I expect.  It's normal
> in Emacs to do that, isn't it?

I think in cases like that, it's useful to see the closure, since that's 
information that can help the user debug a problem. For example, if I 
have something like the following, it's helpful to see information about 
the closure:

  (let ((foo 1))
    (add-hook 'prog-mode-hook (lambda () (setq foo 1))))

In that case, the value of prog-mode-hook is:

  ((closure ((foo . 1) t) nil (setq foo 1)))

This is a contrived example, but similar sorts of things crop up in the 
real world. If the above example were significantly more complex (e.g. 
the `let' and the `add-hook' were in different functions), I might not 
realize that `foo' was lexically-bound unless I looked at the value of 
`prog-mode-hook' and saw the closure.

As such, I think the current behavior is better than simply showing what 
the user typed, i.e. "(lambda () ...)". That doesn't show the variables 
bound by the closure. However, the specific representation of the 
closure object could use some improvement. For example, I don't know 
what purpose the `t' and `nil' serve, although I'm sure both are useful 
to experts in some situations. Is there a way to represent all this 
information in a way that's easy for users to understand without 
expecting them to know the details of how closures are implemented in Emacs?




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

Previous Next


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