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: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Philipp Stephani <p.stephani2 <at> gmail.com>, Filipp Gunbin <fgunbin <at> fastmail.fm>, Eli Zaretskii <eliz <at> gnu.org>, 52063 <at> debbugs.gnu.org
Subject: bug#52063: 28.0.60; Confusing presentation of lambda
Date: Thu, 25 Nov 2021 14:07:45 -0500
> Depends on the length of the lexical list, though:
>
> (pp-emacs-lisp-code
>  (let ((bar 1))
>    (lambda (f) (setq foo bar) (setq foo bar))))
> =>
> (closure ((bar . 1) t) (f)
>   (setq foo bar)
>   (setq foo bar))
>
> can be unwieldy if the list is long.

[ Taking a step back and ignoring practical concerns like whether it's
  easy to implement efficiently.  ]

We could have something like:

    (let ((foo 1)
          (bar 2)
          (baz 5))
      (lambda (x) (+ x bar)))

return an object like

    (closure (x) ((bar . 2))
      (+ x bar))

instead of the current

    (closure ((baz . 5) (bar . 2) (foo . 1) t) (x)
      (+ x bar))

IOW, the final `t` can be dispensed with, we could swap the arglist and
the captured environment, and we could filter the environment to only
include variables which are actually used inside the function.


        Stefan





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

Previous Next


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