all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: Richard Stallman <rms@gnu.org>,  emacs-devel <emacs-devel@gnu.org>
Subject: Re: How to cause a compiler warning?
Date: Mon, 15 Jan 2024 00:16:34 +0000	[thread overview]
Message-ID: <87v87ve9i5.fsf@gmail.com> (raw)
In-Reply-To: <ZaQKF46qVTm8P6uR@ACM> (Alan Mackenzie's message of "Sun, 14 Jan 2024 16:21:43 +0000")

Alan Mackenzie <acm@muc.de> writes:

>>      Most assuredly not.  This may give an incorrect file position for
>>      the
>>      warning.
> ...
>>      Since 29.1, the correct function for a warning has been
>>      byte-compile-warn-x.
>
>>    Self-evidently so, of course, the 'x' standing for "correct".
>
> Something like that, yes.

I've had a better look at the 'byte-compile-warn-x' helper.  I think I
understand what it does, but the docstring leaves to be desired, it says
the first argument a "source element, likely a symbol with position",
which is vague and curious nomenclature I've not seen in other Lisps.

More importantly, is there always a "source element" to give to
byte-compile-warn-x?  Doesn't it depend on the case?

Many macros operate on Lisp forms and sometimes there is some obvious
good form to hook onto and presumably this form is either is a
sym-with-pos or has some such symbols inside it.  Like this:

(defmacro fooing (a &rest body)
  (when (eq (car-safe a) 'quote)
    (byte-compile-warn-x a "don't quote me, silly"))
  ...)

Here, I do agree 'byte-compile-warn-x' is much better than
'byte-compile-warn', as Flymake highlights exactly the symbol in that
position.  Great.

But macros are also just functions and sometimes they need to warn
because... it's Wednesday or something.

(defmacro define-foos (howmanyfoos)
  (when (its-wednesday)
    (byte-compile-warn "Beware code compiled on wednesdays!"))
  ...)

Here, 'byte-compile-warn', which makes the whole 'define-foos'
highlighted by Flymake is not only perfectly valid but also the only
viable option.

So I don't think byte-compiler-warn-x is "most assuredly" the only util
you should use.  If it were, byte-compiler-warn might as well be
deprecated.

>>    Anyway, what about <29 compatible code?
>
> What about it?  Richard isn't working on < 29 code at the moment.

Alright, but since you were so assertive in overriding my suggestion
with a fairly new util, maybe you could comment on what to do in code
intended to work in those versions, for the benefit of others.

João



  reply	other threads:[~2024-01-15  0:16 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 [this message]
2024-01-17 12:25           ` Alan Mackenzie
2024-01-17 13:40             ` João Távora
2024-01-18 12:05               ` Alan Mackenzie
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v87ve9i5.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.