help-gnu-emacs
[Top][All Lists]
Advanced

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

Advice functions: required args that byte-compiler warns are unused


From: Drew Adams
Subject: Advice functions: required args that byte-compiler warns are unused
Date: Wed, 3 Nov 2021 17:53:09 +0000

I'm wondering how you deal with this - what's a
good way.

I have an advice function `my-foo-after-advice',
which I use as an :after advice for function `foo':

 (defun my-foo-after-advice (&rest args)
   "..."
   (ignore args)      ; Quiet the byte-compiler.
   (do-stuff-that-doesnt-refer-to-ARGS))

Suppose function `foo' requires 3 arguments:

 (defun foo (a b c) ...)

An :after advice needs to accept the same args as
the function it advises.  But the byte-compiler
warns "Unused lexical argument 'args'" (naturally).

So I've been adding an `(ignore args)'.

Is there a better way to suppress such a warning?
I looked for a `declare' possibility for this,
which would be a declaration to the byte-compiler
rather than a runtime operation.

Of course `ignore' doesn't cost much here, but it
seems like we should be able to keep info for the
compiler separate from code that gets run.

Hope I'm missing something simple.

<<attachment: winmail.dat>>


reply via email to

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