GNU bug report logs - #51695
29.0.50; lexical scope closure, interactive spec byte compiler warnings/usage issue

Previous Next

Package: emacs;

Reported by: Emanuel Berg <moasenwood <at> zoho.eu>

Date: Mon, 8 Nov 2021 23:41:02 UTC

Severity: normal

Tags: confirmed

Found in version 29.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Emanuel Berg <moasenwood <at> zoho.eu>
To: 51695 <at> debbugs.gnu.org
Subject: bug#51695: 29.0.50; lexical scope closure, interactive spec byte compiler warnings/usage issue
Date: Wed, 10 Nov 2021 02:50:47 +0100
Michael Heerdegen wrote:

> Since one seems to need to make use of the global
> environment at some point, I suggest to use a named function
> as workaround, like in
>
> #+begin_src emacs-lisp
> (let* ((data-item 1)
>        (more-data 2))
>   (defalias 'echo-data--interactive
>     (lambda ()
>       (list (read-number "number: " (or data-item more-data)))))
>   (declare-function echo-data--interactive test) ;defun was not top-level
>   (defun echo-data (&optional data)
>     (interactive (echo-data--interactive))
>     (message "data: %s" (or data data-item)) ))
> #+end_src

Thanks, I wrote this to illustrate the situation but
interesting nonetheless, I don't think I've seen `defalias' to
a `lambda' before and also didn't think of putting
`declare-function' within the `let' body ... practical.

-- 
underground experts united
https://dataswamp.org/~incal





This bug report was last modified 2 years and 244 days ago.

Previous Next


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