GNU bug report logs - #69521
29.1; Adding a DECLARE spec equivalent to DECLARE-FUNCTION

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Adam Porter <adam@HIDDEN>; merged with #74765; dated Sun, 3 Mar 2024 10:50:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 69521 74765. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Removed tag(s) moreinfo. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 69521 <at> debbugs.gnu.org:


Received: (at 69521) by debbugs.gnu.org; 2 Mar 2025 03:49:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 01 22:49:49 2025
Received: from localhost ([127.0.0.1]:49302 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1toaKq-0007au-N4
	for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 22:49:49 -0500
Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:44265)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1toaKo-0007aI-H8
 for 69521 <at> debbugs.gnu.org; Sat, 01 Mar 2025 22:49:47 -0500
Received: by mail-ed1-x536.google.com with SMTP id
 4fb4d7f45d1cf-5e095d47a25so5975408a12.0
 for <69521 <at> debbugs.gnu.org>; Sat, 01 Mar 2025 19:49:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740887380; x=1741492180; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=gMPKFMQ2Mn0HBwQ9NBVzVVivqUFNPYKtIahsqhf+QkA=;
 b=ituaxqRXDfowCkPM1CJQzcWrhOElLSyMyqha2OtPuoiqg8e63w3/sgL/4o/muALM8Q
 WlVT9KvzgLcwScpw9vf8TTAbsWXf9Yjiivn+F2L5HRMYNYzfUkuvjpeu3JUUQnrFM/9u
 +Qj03QM2MwMUTfMmcJm/urVkVdiugqiN5z2E1Zpg9y+8z5mZWkt7+zKXJ0D3gZWwMhf0
 zErUr6QCXDIdc6ewwoWge5C+MzMUy9jBGYZl9EHE3x0nyjax//ZPxytg4T7qLhQcgxH6
 TKBFyM6Wn/dHKk5g4YLhfPx2W7DinV6MptIGLYb5x4FqOiOhOmcQT+MwNH3vVORrYGDN
 3PPQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740887380; x=1741492180;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=gMPKFMQ2Mn0HBwQ9NBVzVVivqUFNPYKtIahsqhf+QkA=;
 b=IFjvgsCrjLQTI/NlwWlV1sjqjw/UoOK0XelSmmfrt4RHziF2lC6ZsDk5KPBnGkGhl+
 jjdcHBct+6TNNr8fkfsHrKAziX9WHzsc7+0Vzqm+kfQZYWh9xUaWQ8P+mpee/FVYnoZv
 ULAHbitVsQW1QoEg38JxFZNE1faqNHac3cmiq6zbX1tz4MiVD/xolqpikLT5iv7T9WMj
 I7JTD2wBWkETQfraz+sDpKHJlf48TLeZBYHo0koObUF9CclxskUuw43EaGxRE1jFRMk2
 yfpKVBPfMiqL6h0AokgiTBzG4mLyWXBqPmZ2jhF6L8SiiHITAp4IV0bSpiHoAHbb8VdS
 e9wQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCUSqnt3jlco1bN5Dm8utvoNdQJLXRzlOH6M7t4k0UU6SL6MnOAUCulZ/eGW3kz3cmaoYPEfBQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YxeDXHgIK1epuNZx4/SqZZwLfO8vHHD0Gp+dgcfxWpxQkXe+RzB
 I/rBw4/qkZKScloWL9+sKhhyc8GscIP4q5auU6JZINPAOGMu8bdbZjd68uvFW96qDJ0rb4UDOv+
 bmKUniDu+nXXlDd9sLUUhAPKa16I=
X-Gm-Gg: ASbGncsKDql1t3XluAxzsD27Ttt3hDvEyPp9uwnlOyxGLTqz+olKLVqkOAtqYyNX8U0
 61jDXUafY+7DhvPoJyeYdWV3mLlBI6yonoOBuAkcB2+kKWy53rLaQ76lvKnrF0O6jYeMusAy1Ic
 +Bp0wFfAyqbjxOZjkS+Ils7Q1Lyw==
X-Google-Smtp-Source: AGHT+IHOT1x0pvfWUnDlCW4xxKoTAU8BEOWxzDOljXgC7daPiliRY49Zm/FEDDupCUmTLD/JhnUxERK0MwhS2UZE3Lk=
X-Received: by 2002:a05:6402:1d49:b0:5e4:9726:7779 with SMTP id
 4fb4d7f45d1cf-5e4d6aca16amr8456145a12.2.1740887380399; Sat, 01 Mar 2025
 19:49:40 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 1 Mar 2025 19:49:40 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <babbe557-0506-471f-b074-3d36d34d397c@HIDDEN>
References: <b7ea82de-7c7b-48ad-8352-df35a56e0143@HIDDEN>
 <86frx7o96x.fsf@HIDDEN> <babbe557-0506-471f-b074-3d36d34d397c@HIDDEN>
MIME-Version: 1.0
Date: Sat, 1 Mar 2025 19:49:40 -0800
X-Gm-Features: AQ5f1JrPiKKgGEyBkvVLue_ZV3ZH_V8tq3EGg49dQgxlMVeqX6ylPdUE0xEVxL4
Message-ID: <CADwFkmkQRE7xNeZUJ70EOCnyr-dA3z5NBGhaaMAeUCgBSj+MMg@HIDDEN>
Subject: Re: bug#69521: 29.1;
 Adding a DECLARE spec equivalent to DECLARE-FUNCTION
To: Adam Porter <adam@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69521
Cc: Eli Zaretskii <eliz@HIDDEN>, 69521 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Adam Porter <adam@HIDDEN> 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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69521; Package emacs. Full text available.
Added tag(s) moreinfo. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 69521 <at> debbugs.gnu.org:


Received: (at 69521) by debbugs.gnu.org; 3 Mar 2024 21:04:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 03 16:04:40 2024
Received: from localhost ([127.0.0.1]:41369 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rgt0h-0007IY-TP
	for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 16:04:40 -0500
Received: from black.elm.relay.mailchannels.net ([23.83.212.19]:48246)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <adam@HIDDEN>) id 1rgt0f-0007IQ-TI
 for 69521 <at> debbugs.gnu.org; Sun, 03 Mar 2024 16:04:39 -0500
X-Sender-Id: dreamhost|x-authsender|adam@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 8118C422A3;
 Sun,  3 Mar 2024 21:04:07 +0000 (UTC)
Received: from pdx1-sub0-mail-a202.dreamhost.com (unknown [127.0.0.6])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id 302A142C0F;
 Sun,  3 Mar 2024 21:04:07 +0000 (UTC)
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709499847; a=rsa-sha256;
 cv=none;
 b=DqO9SoUyQoOSu1kzF0Ahed3rldrjlNiaeeI8XQxxSPiocxtz94b6cNVWJ5mWdl+ZYwe7+0
 HFleWFGp1RZbD3+R/3cURlp9gOqtpFgLr0Xo7Zi20tFtlpLlHhdV5rRNme/cHX2zjlMVAM
 lpGpkphGgdc06lckowyRJPdHol0QhCfpYBlqw+U/cfb4WLMvOoW2ZtuwgC2zd/ndJT0yfa
 2PU5+C5qFf9LTcKU6n4I7yW753QFOaYP8eWkVDdPGYGA/WQjc60MwfKtmQ5oEHfyFkEBcX
 wRe2RU1wIxwGxaWZcn8Ljx+0TYDnvaRhVkv7PWkvberFVEYccLl9w1wzlfhhOA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=mailchannels.net; s=arc-2022; t=1709499847;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references:dkim-signature;
 bh=OJ/PiI5ZYK8UGOh1OUuRGiqm4KU7uzdrtJjD0vkn/BE=;
 b=I6NvUK6rS8iOO9sdwI4r92ks4UM9R1X7pxZnagmge/IhBwarO1Lsndi90mSzmvtUgSlKBD
 6ueMfznB+Y4suJiMW+gIQ+I9S/O5pKIk+JH9C7UQZLqKqe0ReVpnvlO5rHc+FxNwfQ8x/Z
 1TabQnQ176PozFflq5295KeKfmDxRR6Q1hVbhxk+4J84nvireDFW2WoBEG31FAHM4x+8LK
 hbIMlDU15Sc2Vg2wLWBm1hAjQpax3k+jHdF2QMKqxyEM0wzdzyvnrLkBadETzGUb/rgoa4
 TnhssgR3rh1YLetC5djxhojjxcAzR8w20d7H7PYwXqiM0xjj1AmJbPetjdviNQ==
ARC-Authentication-Results: i=1; rspamd-7f9dd9fb96-pr8lr;
 auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@HIDDEN
X-Sender-Id: dreamhost|x-authsender|adam@HIDDEN
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|adam@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Imminent-Power: 6803aab1133da4ef_1709499847424_2027902606
X-MC-Loop-Signature: 1709499847424:739313868
X-MC-Ingress-Time: 1709499847424
Received: from pdx1-sub0-mail-a202.dreamhost.com (pop.dreamhost.com
 [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384)
 by 100.104.192.87 (trex/6.9.2); Sun, 03 Mar 2024 21:04:07 +0000
Received: from [10.66.3.66] (unknown [91.193.232.98])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 (Authenticated sender: adam@HIDDEN)
 by pdx1-sub0-mail-a202.dreamhost.com (Postfix) with ESMTPSA id 4TnvT25HXWz9g; 
 Sun,  3 Mar 2024 13:04:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net;
 s=dreamhost; t=1709499847;
 bh=OJ/PiI5ZYK8UGOh1OUuRGiqm4KU7uzdrtJjD0vkn/BE=;
 h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding;
 b=ecDYugDsrydPZVvBtHaKj5wRmUEMtmOVmo4dOHTfY+vV8Jr1wVV6/56hM5P1OJYZb
 pg3PSDAYEbyOGlmFwNQC2Txy5SCrm33C2ND9Kdc/th9YShsqSkMa6d4fF9TvCj1XWk
 zUvuSWutkK4bK8qf+JdcG0Nda5gR0HRtOSW8DwDWqU16xmKejZmlmyuAA5E6484klh
 9iOsNUIGT+/1tn3/5hgne0SuF2rrQdfSWkIXOVerJetZ0juNiLDMnnelZsHZK1VoL0
 COTCs7sV4Jh9X3WCyMErxcH9REgyO8pejwzsH1P9w1S91Nn7fu9N6nNGCTyQ6CmQOP
 MrAjLR/WZKx3A==
Message-ID: <babbe557-0506-471f-b074-3d36d34d397c@HIDDEN>
Date: Sun, 3 Mar 2024 15:04:05 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#69521: 29.1; Adding a DECLARE spec equivalent to
 DECLARE-FUNCTION
Content-Language: en-US
To: Eli Zaretskii <eliz@HIDDEN>
References: <b7ea82de-7c7b-48ad-8352-df35a56e0143@HIDDEN>
 <86frx7o96x.fsf@HIDDEN>
From: Adam Porter <adam@HIDDEN>
In-Reply-To: <86frx7o96x.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.6 (/)
X-Debbugs-Envelope-To: 69521
Cc: 69521 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.4 (/)

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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69521; Package emacs. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Eli Zaretskii <eliz@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 69521 <at> debbugs.gnu.org:


Received: (at 69521) by debbugs.gnu.org; 3 Mar 2024 11:21:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 03 06:21:10 2024
Received: from localhost ([127.0.0.1]:39836 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rgju2-0005OT-GD
	for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 06:21:10 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35122)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>)
 id 1rgjtx-0005Nm-NX; Sun, 03 Mar 2024 06:21:09 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rgjrH-0000kK-UE; Sun, 03 Mar 2024 06:18:19 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=RNk3inunL4o+rDe8iy39q6eEb5wpf+Vp8EBRS63jz+M=; b=NwjS2lYTWD/v
 KOCWpIRsDPRjiCe8fYZyKE2x6pE1m9D68DREzM4RZg++2eTBgTs5XTF19NEAqfisBQpL8YzwKboCI
 M55omGZ1JAxh+aaZ/u6U7/6t0+BNCjApg1o0lZb+wp4d9pHyGg8HpC6mCNIafzVESqJ7uWTpiQjz2
 N3+DMhbZydSeC62idNxLqcuJloKPJ8bZmkQ1Wsc7CA1xn9ue7Fkr7UnUpyDJlTOFWUTjPr9Q3jT7l
 R01cJRUuoX2Z7U4rQmVBBENAWEhFUMYeAS4DkbETLIX3rHMwzLYippcYaF7BdmSljBdqcTAdhzkRb
 /CChHl1u2MJ2gSJXtR0qlQ==;
Date: Sun, 03 Mar 2024 13:18:14 +0200
Message-Id: <86frx7o96x.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Adam Porter <adam@HIDDEN>
In-Reply-To: <b7ea82de-7c7b-48ad-8352-df35a56e0143@HIDDEN> (message
 from Adam Porter on Sun, 3 Mar 2024 04:49:02 -0600)
Subject: Re: bug#69521: 29.1;
 Adding a DECLARE spec equivalent to DECLARE-FUNCTION
References: <b7ea82de-7c7b-48ad-8352-df35a56e0143@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69521
Cc: 69521 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

severity 69521 wishlist
thanks

> Date: Sun, 3 Mar 2024 04:49:02 -0600
> From: Adam Porter <adam@HIDDEN>
> 
> In light of [this thread], this seems like a good time to propose this
> idea: to enhance the `declare' form with a `function' spec equivalent to
> the top-level `declare-function' form.  This allows keeping the
> declaration inside the function that makes it necessary, which has a few
> advantages:

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.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69521; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Mar 2024 10:49:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 03 05:49:42 2024
Received: from localhost ([127.0.0.1]:39813 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rgjPZ-0004bO-Pj
	for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 05:49:42 -0500
Received: from lists.gnu.org ([209.51.188.17]:36102)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <adam@HIDDEN>) id 1rgjPV-0004bB-3e
 for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 05:49:40 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <adam@HIDDEN>)
 id 1rgjP1-0001ri-S8
 for bug-gnu-emacs@HIDDEN; Sun, 03 Mar 2024 05:49:07 -0500
Received: from quail.birch.relay.mailchannels.net ([23.83.209.151])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <adam@HIDDEN>)
 id 1rgjP0-0001BV-Gw
 for bug-gnu-emacs@HIDDEN; Sun, 03 Mar 2024 05:49:07 -0500
X-Sender-Id: dreamhost|x-authsender|adam@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 33B6CC11BE
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Mar 2024 10:49:04 +0000 (UTC)
Received: from pdx1-sub0-mail-a203.dreamhost.com (unknown [127.0.0.6])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id C34E3C10CD
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Mar 2024 10:49:03 +0000 (UTC)
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709462943; a=rsa-sha256;
 cv=none;
 b=HBBVuQdDxLNd50EkN4wYELcd0dcegBjpPHg8smKqO5Z9UQvMMxn84evOnjGEK1+LqBSS+V
 rkTiBsWLVledvCqPSZPqs/6YJnRbtrjUVojJ7MQgzcD0D9yaWLFaU6ny5Z6ym5hY/Nikkj
 uTFSrlHZH2IwsvKNOcbURiDgpS9jxvA+8a6XoQsEZxlky8AUBjnWH5/zvNCODzHHmcgIif
 ocjM5XJUf9tSntdOFOAS1elJgwvqldaO4PhxbtMusEK7cddk9D1Z27bCff9F5h17lue3tB
 zN/7hdWzLDfJdalH2EW9x0Y1G8oP0hC7aw/QreyASBIMAZMxb39zztSaNo+1Gg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=mailchannels.net; s=arc-2022; t=1709462943;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:dkim-signature;
 bh=rQjqMxpId+M34TvRrtskiJTg/96Q1HmW+40Kg5sYFO4=;
 b=nMqzlkf22JfaAnUDrEKVGZq1XV2RYpuZWi1XpNAwsictu8ue0ks5jswg8G9HaEK47H4TFB
 GI+7otPZHMT4mWG+oiTjBbknkvm8vg9iZzwsFusBZ1dJmO++/Bp5loq7TztOAdENEjbYNu
 H5oE/ktK5ZGCx2Hvz9GZys38gH/IKl4vPX0DwhS9Vn5fwS7tMGZ3xeIB9km2nh/xpHA1/7
 y0ygaZU1lb5Z0deRVF/YestG86r9j+H7DGyTAn2uFC8Lqmxd0OoAXzf+x4mfG5b/A3VbtR
 V7gszmXZ1ti4hD9VShbCdnEzNgilLerpjF8kySa4FzotCidojkHQEWiIBTploQ==
ARC-Authentication-Results: i=1; rspamd-7f9dd9fb96-cdljl;
 auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@HIDDEN
X-Sender-Id: dreamhost|x-authsender|adam@HIDDEN
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|adam@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Trouble-Wiry: 5ef3f8f50a38359b_1709462944029_819258068
X-MC-Loop-Signature: 1709462944028:2880327590
X-MC-Ingress-Time: 1709462944027
Received: from pdx1-sub0-mail-a203.dreamhost.com (pop.dreamhost.com
 [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384)
 by 100.111.192.177 (trex/6.9.2); Sun, 03 Mar 2024 10:49:04 +0000
Received: from [10.28.0.30] (unknown [45.131.192.18])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 (Authenticated sender: adam@HIDDEN)
 by pdx1-sub0-mail-a203.dreamhost.com (Postfix) with ESMTPSA id 4TndqM287fzGs
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Mar 2024 02:49:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net;
 s=dreamhost; t=1709462943;
 bh=rQjqMxpId+M34TvRrtskiJTg/96Q1HmW+40Kg5sYFO4=;
 h=Date:To:From:Subject:Content-Type:Content-Transfer-Encoding;
 b=OBl9Ds3veh2qtof67zaeyFF3psSZzCee/uhE/L358nAzl/T/UZONguAxhSTaKPFft
 21rc/gOcm9q1842yZbd3cwjTA9gu4V1eJbR1SPOo8TJsHjXjatfMH77KMjcFCvD3fX
 6GJl+Qtd5LHizxdnsvDbl7AP4fj94H8m7Y22PVxitwxGS2sR2mdzGqSWbXIPKFLfZZ
 DPS8vXd6Zu8gnE+ua6FAZ4paNmq/7sUw/hQ7//n3czan0SXgMNu86NrsZKTGXVHlrB
 6zZglb+AoEoGgGoU0dCxAxNyBefuZ8UDcmvTjatWnMZN9ymOWBDJ4dKJi+nkI++c/B
 lAXaxt978MqOg==
Message-ID: <b7ea82de-7c7b-48ad-8352-df35a56e0143@HIDDEN>
Date: Sun, 3 Mar 2024 04:49:02 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
To: bug-gnu-emacs@HIDDEN
From: Adam Porter <adam@HIDDEN>
Subject: 29.1; Adding a DECLARE spec equivalent to DECLARE-FUNCTION
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Received-SPF: neutral client-ip=23.83.209.151; envelope-from=adam@HIDDEN;
 helo=quail.birch.relay.mailchannels.net
X-Spam_score_int: 0
X-Spam_score: -0.0
X-Spam_bar: /
X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,
 RCVD_IN_VALIDITY_RPBL=1.31, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.7 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

Hi,

In light of [this thread], this seems like a good time to propose this
idea: to enhance the `declare' form with a `function' spec equivalent to
the top-level `declare-function' form.  This allows keeping the
declaration inside the function that makes it necessary, which has a few
advantages:

1. It clearly indicates which function makes the declaration necessary
    (i.e. which function contains calls to the function in another
    library).
2. If the function is moved to another file, the declaration moves with
    it.
3. If the function is removed, the declaration is removed with it.
4. It reduces the number of top-level forms.

Also, it seems like a natural fit, i.e. `declare-function' to `(declare
(function ...))'.

As an experiment, I implemented this in [Ement] about 10 months ago, and
I've neither seen nor heard of any problems with it.  Here's the code
that implements it:

┌────
│ (eval-and-compile
│   (defun ement--byte-run--declare-function (_name _args &rest values)
│     "Return a `declare-function' form with VALUES.
│ Allows the use of a form like:
│
│   (declare (function FN FILE ...))
│
│ inside of a function definition, effectively keeping its
│ `declare-function' form inside the function definition, ensuring
│ that stray such forms don't remain if the function is removed."
│     `(declare-function ,@values))
│
│   (cl-pushnew '(function ement--byte-run--declare-function) 
defun-declarations-alist :test #'equal)
│   (cl-pushnew '(function ement--byte-run--declare-function) 
macro-declarations-alist :test #'equal))
└────

In use, it looks like this:

┌────
│ (defun ement-notifications--make (notification)
│   "Return an `ement-notification' struct for NOTIFICATION.
│ NOTIFICATION is an alist representing a notification returned
│ from the \"/notifications\" endpoint.  The notification's event
│ is passed through `ement--make-event'."
│   (declare (function ement--make-event "ement"))
│   (pcase-let (((map room_id _actions _ts event read) notification))
│     (make-ement-notification :room-id room_id :readp read
│                              :event (ement--make-event event))))
└────

Would this be an acceptable addition to Emacs Lisp?  If so, I'd be glad
to prepare a patch.

Thanks, Adam


[this thread]
<https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00057.html>

[Ement] <https://elpa.gnu.org/packages/ement.html>




Acknowledgement sent to Adam Porter <adam@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#69521; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 2 Mar 2025 04:45:04 UTC

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