GNU bug report logs - #5863
defadvice in byte compiled file does not work

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Thu, 8 Apr 2010 15:27:02 UTC

Severity: minor

Tags: wontfix

Merged with 21683

Found in version 25.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Kangas <stefan <at> marxist.se>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5863 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>, Lennart Borgman <lennart.borgman <at> gmail.com>
Subject: bug#5863: defadvice in byte compiled file does not work
Date: Wed, 18 Nov 2020 19:23:05 -0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> The info page I pointed to says that defadvice should work for
>> primitives called from lisp code.  And that is what does not work for
>> me here.
>
> For such uses, there are several categories of functions:
> - functions that have their own byte-code (things like widen, car, cdr, ...).
> - functions that are implemented in C but don't have their own
>   byte-code.
> - other functions.
>
> Pieces of advice on the first kind of functions only work for
> calls from interpreted Lisp code.
> Pieces of advice on the second kind of functions only work for
> calls from Lisp code (both interpreted and byte-compiled).

BTW, it seems like advising primitives will work once we get native-comp
merged:

  The result of this procedure is that each newly activated function will
  use the trampoline in place of the original primitive and the
  trampoline will execute the call going through funcall making the
  advice effective!

  This works so well that in-fact now is even possible to advice
  effectively what wasn't effective in byte-code (ex the + function). But
  hey, don't try this a home!

  https://akrl.sdf.org/gccemacs.html#org3b7398e

I'm not sure how this would affect the status of this bug, if at all.
Perhaps we could expand the description of why advising primitives is a
bad idea in the Info node `(elisp) Advising Named Functions':

  It is possible to advise a primitive (*note What Is a Function::),
  but one should typically _not_ do so, for two reasons.  Firstly, some
  primitives are used by the advice mechanism, and advising them could
  cause an infinite recursion.  Secondly, many primitives are called
  directly from C, and such calls ignore advice; hence, one ends up in a
  confusing situation where some calls (occurring from Lisp code) obey the
  advice and other calls (from C code) do not.

We could perhaps simply say that advice on primitives with their own
bytecode will be ineffective if the code is run byte-compiled.




This bug report was last modified 4 years and 172 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.