bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#52063: 28.0.60; Confusing presentation of lambda


From: Jim Porter
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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]