From: Alan Mackenzie <acm@muc.de>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: acm@muc.de, Stefan Monnier <monnier@iro.umontreal.ca>,
21466@debbugs.gnu.org
Subject: bug#21466: [PATCH] Avoid defining (temporarily) vars and functions
Date: Sat, 26 Mar 2022 14:45:40 +0000 [thread overview]
Message-ID: <Yj8nFNRKwUdx830s@ACM> (raw)
In-Reply-To: <87y2105swg.fsf@gnus.org>
Hello again, Lars.
On Wed, Mar 23, 2022 at 21:13:35 +0100, Lars Ingebrigtsen wrote:
> Alan Mackenzie <acm@muc.de> writes:
> > So, I don't object on principle to the principle of the patch, just
> > there are these little irritations about it, and it will need me to
> > study it more closely to check nothing subtle would get lost (I doubt it
> > would).
> The patch no longer applied to Emacs 29, so I've respun it.
[ .... ]
> However, it leads to a number of warnings when compiling, so either my
> respin is faulty, or something's changed to make it not work any more?
Maybe it didn't work properly back in 2015, I didn't actually get around
to trying it out, then.
> In c-fontify-recorded-types-and-refs:
> progmodes/cc-fonts.el:491:8: Warning: function `c-fontify-recorded-types-and-refs' defined multiple times in this file
> ELC progmodes/cc-styles.elc
> In c-font-lock-declarators:
> progmodes/cc-fonts.el:1063:8: Warning: function `c-font-lock-declarators' defined multiple times in this file
> progmodes/cc-fonts.el:2300:35: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2300:35: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2496:37: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2496:37: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2501:37: Warning: reference to free variable `c-reference-face-name'
> In c-font-lock-objc-method:
> progmodes/cc-fonts.el:2527:8: Warning: function `c-font-lock-objc-method' defined multiple times in this file
> progmodes/cc-fonts.el:2602:38: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2602:38: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2650:38: Warning: reference to free variable `c-reference-face-name'
> progmodes/cc-fonts.el:2678:37: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2678:37: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2683:37: Warning: reference to free variable `c-reference-face-name'
> progmodes/cc-fonts.el:2711:38: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2711:38: Warning: reference to free variable `c-preprocessor-face-name'
> progmodes/cc-fonts.el:2716:38: Warning: reference to free variable `c-reference-face-name'
The patch is essentially replacing cc-bytecomp-defvar by (defvar foo),
and cc-bytecomp-defun by (declare-function 'foo nil). These are only
approximately similar.
cc-bytecomp-def{var,fun} are like C's extern. They say "this
variable/function will be defined somewhere else".
By contrast, (defvar foo) doesn't really do anything (?except marking
any possible foo as a special variable). (declare-function 'foo nil)
says "This function HAS ALREADY been defined somewhere else (and don't
you dare redefine it!)."
These explain the "free variable" warnings for the variables and the
"defined multiple times" warnings for the functions.
To sort out this bug properly, we really need Lisp functions equivalent
to C's extern. (defvar foo) and (declare-function 'foo nil) currently
don't fill this need.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2022-03-26 14:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-12 3:36 bug#21466: [PATCH] Avoid defining (temporarily) vars and functions Stefan Monnier
2015-10-29 13:09 ` Stefan Monnier
2019-11-06 1:29 ` Stefan Kangas
2021-05-10 11:45 ` Lars Ingebrigtsen
2021-05-11 20:34 ` Alan Mackenzie
[not found] ` <YJrqVlJR4iMvf2s1@ACM>
2021-05-11 22:03 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-23 13:14 ` Lars Ingebrigtsen
2021-07-23 15:01 ` Glenn Morris
2021-07-24 10:26 ` Lars Ingebrigtsen
2022-03-23 20:13 ` Lars Ingebrigtsen
2022-03-25 21:09 ` Alan Mackenzie
2022-03-26 14:45 ` Alan Mackenzie [this message]
2022-03-26 16:47 ` Lars Ingebrigtsen
2022-03-26 19:51 ` Alan Mackenzie
2022-03-29 12:26 ` Lars Ingebrigtsen
2022-03-29 21:02 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yj8nFNRKwUdx830s@ACM \
--to=acm@muc.de \
--cc=21466@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).