emacs-devel
[Top][All Lists]
Advanced

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

Re: Dealing with obsoletion warnings in non-core code


From: Stefan Monnier
Subject: Re: Dealing with obsoletion warnings in non-core code
Date: Mon, 28 Sep 2020 13:32:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> The same trick however cannot be used for functions/variables declared
> obsoleted, the only construct I've found to work in this case is the
> following:
>
>     (with-suppressed-warnings ((obsolete old-but-useful-function))
>       (if (fboundp 'recommended-function)
>           (recommended-function)
>         (old-but-useful-function)))
>
> Ideally I'd like to be able to write the following instead to avoid the
> needless repetition:
>
>     (if (fboundp 'recommended-function)
>         (recommended-function)
>       (old-but-useful-function))

Indeed, it's a problem of which I'm aware but I don't know how to solve
it nicely.  Here's my thoughts about it so far:

I see how I could silence the obsolescence warning for:

      (if (fboundp 'old-but-useful-function)
          (old-but-useful-function)
        (recommended-function))

but that then gives you byte-compile warnings in older Emacsen because
of the use of a `recommended-function` they don't know about, and more
problematically it makes your code keep using the obsolete function even
when the all-dancing-all-singing `recommended-function` is
already available.

I guess we could try and add some kind of database of "replacements", so
when the byte-compiler sees (fboundp 'recommended-function) it knows to
silence warnings for `old-but-useful-function`, but that seems terribly
ad-hoc, will likely only work for some particular cases, and requires
the programmer to be aware of which `recommend-function` to test in
order to silence the warning.  Maybe it's still worth doing,
I don't know.


        Stefan




reply via email to

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