emacs-devel
[Top][All Lists]
Advanced

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

Re: Last use of defadvice in Emacs


From: Eli Zaretskii
Subject: Re: Last use of defadvice in Emacs
Date: Thu, 07 Apr 2022 09:14:47 +0300

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Alan Mackenzie <acm@muc.de>,  bug-cc-mode@gnu.org,  emacs-devel@gnu.org
> Date: Wed, 06 Apr 2022 22:49:08 -0400
> 
> > Could you give some tips on what issues one might see with defadvice
> > and its disrespect of lexical bindings?
> 
> IIRC for existing pieces of advice the main issue can occur if an advice
> accesses the formal arguments by their name rather than via things like
> `ad-get-arg`.  IIRC we managed to get it working like it used to in most
> cases, but it's not very robust.
> 
> The other issue is that the body of `defadvice` is always evaluated in
> the dynamically scoped dialect of ELisp.  This means that its local vars
> can "leak" to some of the functions they call (as is normal with
> dynamic scoping) and that they can't refer to surrounding lexical
> variables (more common with `ad-make-advice` than with `defadvice` since
> that one is usually used at top-level), ...
> 
> Those problems aren't new.  What's "new" is that `advice-add` doesn't
> suffer from them.

It would be nice if these issues (perhaps in less academic shape and
in more practical terms) could be added to the ELisp manual, because
AFAICT we currently lack any rationale for people not to use
defadvice.



reply via email to

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