From: Alan Mackenzie <acm@muc.de>
To: "João Távora" <joaotavora@gmail.com>
Cc: Richard Stallman <rms@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: How to cause a compiler warning?
Date: Thu, 18 Jan 2024 12:05:33 +0000 [thread overview]
Message-ID: <ZakUDXTVh4TXedjO@ACM> (raw)
In-Reply-To: <CALDnm52jAaU-sNv0zwYYdKT2PL9QOKV6iBCadzevfwHmHW_TeQ@mail.gmail.com>
Hello, João.
On Wed, Jan 17, 2024 at 13:40:04 +0000, João Távora wrote:
> On Wed, Jan 17, 2024 at 12:25 PM Alan Mackenzie <acm@muc.de> wrote:
> > ARG can be any Lisp form at all. How would you reformulate the doc
> > string to make it less vague and curious?
> Call it FORM. Then add in the text you wrote to Richard, who
> seem to have also been confused.
FORM is unsuitable, because in the byte compiler it always means the
form currently being compiled. Besides in macroexp-warn-and-return,
there's already a parameter called FORM.
Maybe POS would do. But that could mislead people into giving a number
rather than a symbol with position.
> I got the idea of it pretty quickly, even with the ARG naming,
> so take that as a data point.
> > Really? Can you point out any such existing macro in the source files
> > of the byte compiler? You must be aware that warning messages without
> > source code locations are annoying in the extreme.
> Not all macros process forms. Just search for a macro without arguments.
Hmmm.
> > source code locations are annoying in the extreme.
> That's a bit of an extreme statement.
I don't think so. A workflow so prevalent as to count as universal is
to compile a .el file, look at the list of warnings and to jump to the
source position of each warning and fix it. A warning without a
position (or a wrong position) blocks this workflow.
> Macros that don't process source code and are used simply to
> generate Lisp code don't have anything else to report. So using
> byte-compiler-warn is fine and you'll see the macro invocation
> itself highlighted.
What do you mean, "you'll see the macro invocation itself highlighted"?
You certainly won't in a batch compilation, and I don't recall seeing
anything highlighted anywhere for a compilation from within a running
Emacs. In which window would this highlighting appear?
If such a macro does generate a warning, it should give as position a
symbol in its own code to direct the user to the location which needs
fixing. byte-compile-warn is not fine; it doesn't give any location.
> > byte-compile-warn-x is intended for use in the byte compiler. Anybody
> > doing work there should be sophisticated enough to understand what to
> > do. In macros which extend the Lisp language, there is
> > macroexp-warn-and-return, for anybody who can understand it. Do people
> > actually write such language extensions and expect them to work on old
> > Emacs versions? There may be, but I'm not aware of any.
> I write macros that are supposed to work back to Emacs 26 yes.
That doesn't address my question. I was asking about macros WHICH
EXTEND THE LISP LANGUAGE. Things like pcase, or Richard's new cond*.
> I frequently don't bother with byte-compiler-errors as I tend to let
> the other macros and special forms my macro expands to do that. But
> not necessarily always.
Why are you using the byte compiler warning functions anyway? Some of
the time, these macros will be interpreted, not compiled, so these
functions are thus inappropriate. byte-compile-warn-x is for the use of
the byte compiler.
> My point is you shouldn't make this a hard rule with such dogmatism.
You haven't convinced me. byte-compile-warn is obsolete and has been
superseded. It gives no position information. Before Emacs 29, it used
to try to give position info, which it frequently got wrong.
You haven't identified a concrete case where byte-compile-warn-x would
be inappropriate, or difficult to use. If it's a matter of backward
compatibility, then something in that compatibility library (whose name
I can't remember) would seem to be the thing.
> But it was fine to suggest byte-compile-warn-x, which I didn't
> know about, so thanks.
My pleasure!
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2024-01-18 12:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-14 3:09 How to cause a compiler warning? Richard Stallman
2024-01-14 3:20 ` João Távora
2024-01-14 13:01 ` Alan Mackenzie
2024-01-14 15:43 ` João Távora
2024-01-14 16:21 ` Alan Mackenzie
2024-01-15 0:16 ` João Távora
2024-01-17 12:25 ` Alan Mackenzie
2024-01-17 13:40 ` João Távora
2024-01-18 12:05 ` Alan Mackenzie [this message]
2024-01-18 12:26 ` João Távora
2024-01-14 15:54 ` Ihor Radchenko
2024-01-14 16:26 ` Alan Mackenzie
2024-01-17 3:29 ` Richard Stallman
2024-01-17 11:59 ` Alan Mackenzie
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=ZakUDXTVh4TXedjO@ACM \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
--cc=rms@gnu.org \
/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).