Subject: Re: bug#69521: 29.1; Adding a DECLARE spec equivalent to DECLARE-FUNCTION

From: Stefan Kangas <[email-masked]>
Date: Sat, 1 Mar 2025 19:49:40 -0800

Adam Porter <[email-masked]> writes:

> On 3/3/24 05:18, Eli Zaretskii wrote:
>
>> Thanks, but I think this should be discussed on emacs-devel first.
>> The bug tracker is not a good vessel of discussing ideas; in
>> particular. quite a few of people who should be part of such a
>> discussion don't read bug-gnu-emacs regularly, and must be explicitly
>> CC'ed to take notice.
>> So I suggest to start the discussion on emacs-devel, and only switch
>> here if/when the idea and its implementation aspects are clear enough
>> to post a patch.
>
> Ok, I filed the bug report because I had mentioned it in that thread and it
> seemed to get overlooked.  Now I've posted a new thread.  Please see:
>
> https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00118.html

In that thread, Basil wrote:

    My vote is for instead teaching the compiler to treat
    declare-function more like it treats defvar, in that the effect of
    declare-function should be made local to the current lexical scope.
    [It is already possible to write this way, and I've been known to,
    but sadly the effect is global.]  This wish has been raised and
    agreed on here (at least in passing) before.

    This would reap all the benefits of points 1-4, as well as an
    additional one: that declare-function is lexically closer to the
    implementation through which the need for the declaration arises.  I
    think a declaration at the top of a function is more likely to be
    forgotten and become stale as the implementation changes.

FWIW, I'd very much welcome such a change.

Adam, are you interested in working on that?