emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to cause a compiler warning?


From: Alan Mackenzie
Subject: Re: How to cause a compiler warning?
Date: Wed, 17 Jan 2024 11:59:29 +0000

Hello, Richard.

On Tue, Jan 16, 2024 at 22:29:11 -0500, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]

[ .... ]

>   > > > Since 29.1, the correct function for a warning has been
>   > > > byte-compile-warn-x.

>   > > What about `macroexp-warn-and-return'?

>   > It is a complicated way of calling byte-compile-warn-x.

> Since the warning would come from expansion of the cond* macro, I get
> the impression from the doc string that `macroexp-warn-and-return' MAY
> be exactly what I want.  But I can't be quite sure.

I've never really understood macroexp-warn-and-return either.  Its doc
string "Return code equivalent to FORM labeled with warning MSG." is
unhelpful, it being unclear precisely what "equivalent to" and "labeled
with" mean.

macroexp-warn-and-return expands FORM, attaching a call to
byte-compile-warn-x to it, somehow.  There's no documentation of it in
the Elisp manual, so the only way really to understand what it does is by
reading the source code.  But the ARG argument has the same meaning as
ARG in byte-compile-warn-x.

I think Ihor may well understand it, and Stefan Monnier (who wrote it)
certainly does.

My impression is that macroexp-warn-and-return is indeed what you want.

> `byte-compile-warn-x' has a feature of an argument (unhelpfully named ARG)
> which says, 
>     ARG is the source element (likely a symbol with position) central to
>       the warning, intended to supply source position information.

ARG can actually be any Lisp form at all.  Only when it is a symbol with
position, does it supply the source code location for the warning.  When
it is anything else, the location is taken from the most nested element
which is a symbol with position from a stack of forms.

I cannot see how it could be more helpfully named, but am open to
suggestions.

> Does `macroexp-warn-and-return' have a similar feature?

The last &optional parameter ARG has the same meaning, so yes.

> Does it use FORM for that?  If so, it woukd be helpful for its doc
> string to say FORM will be used this way.  With the current doc string
> it is not clear what it WILL do with FORM.

Yes, it uses FORM for that if ARG is not provided.  The doc string does
say this.

> Can someone please clarify these minor points so I can tell what to do?

> Also, it would be good to rename the argument ARG and improve the doc string
> as described above.

> -- 
> Dr Richard Stallman (https://stallman.org)
> Chief GNUisance of the GNU Project (https://gnu.org)
> Founder, Free Software Foundation (https://fsf.org)
> Internet Hall-of-Famer (https://internethalloffame.org)

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]