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

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

bug#66908: Exposing more public nadvice API


From: Stefan Monnier
Subject: bug#66908: Exposing more public nadvice API
Date: Fri, 03 Nov 2023 12:22:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> I would like to ask if it would be possible to have a public and
> "official" way to access information about advised functions, since all
> the accessory functions defined by `oclosure-define' appear to be marked
> as internal.

[ `oclosure-define` always define accessors as internal, indeed.
  I decided it was simpler this way, since it's easy enough to add
  aliases for those accessors we want to export.  ]

> Specifically `advice-cd*r' would be useful,

It's clearly the internal function most frequently used outside of
`nadvice.el`, indeed.
I think it'd be OK to promote that function to a non-internal name.

> though it might be that we (Visuwesh and I) are trying to do the wrong
> thing, since we want the return value to get a more sensible response
> from `func-arity' -- and I recall we had conversations about the
> complexity of this issue in the past before.

There are very few places where `func-arity` can be used reliably,
indeed and most of those cases are better served by
`help-function-arglist`.

In the case where `func-arity` is used for backward compatibility
purposes (where reliability is not really possible anyway), I've
generally recommend the use of

    (condition-case nil
        ...
      (wrong-number-of-aruments
        ...))

instead.  It comes with its own failure modes, of course, but it's
usually easier to use and I found it to fail less often in practice
(because it's not affected by wrappers like those introduced by advice
or `apply-partially`).


        Stefan






reply via email to

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