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: Gregory Heytings
Subject: Re: Dealing with obsoletion warnings in non-core code
Date: Tue, 29 Sep 2020 14:11:40 +0000
User-agent: Alpine 2.22 (NEB 394 2020-01-19)


Hi Stefan,

I gave the two macros a better name, they are now:

(defmacro funcall-no-warn (fun &rest args) `(funcall (intern (symbol-name 
,fun)) ,@args))
(defmacro set-no-warn (var val) `(set (intern (symbol-name ,var)) ,val))

and should be used as follows:

(if (fboundp 'new-function)
    (funcall-no-warn 'new-function arg ...)
  (funcall-no-warn 'old-function arg ...))

(if (boundp 'new-variable)
    (set-no-warn 'new-variable value)
  (set-no-warn 'old-variable value))


That's just obfuscating the code


You probably meant: Indeed, that Just Works^TM, congratulations! ;-)


(which will prevent the compiler from detecting some real errors such as when you have a typo in the function's name or when you don't provide the right number of args)


Indeed. If there's another way to do this while detecting errors at compilation time, that would be even better. OTOH, this will quickly raise a runtime error in case of typos or wrong number of arguments, which is unlikely to get unnoticed by the maintainer. Of course I'm not advocating to use this everywhere.


and might be defeated by compiler optimizations.


It might be, but AFAICS it is not. I forgot to mention that I tested the above macros on Emacs 21, 22, 23, 24, 25, 26, 27 and 28. As I said, it Just Works^TM.


I think the OP's question was how to "do it right", rather than how to work around the problem.


I don't know. It's just my proposed solution. OTOH, I don't see how he could "do it right" when his problem statement mentions that he wants to support old Emacs versions, which by definition nobody can improve anymore.

Your idea of of a database of replacements might work, but it has to be implemented, and for the use case the OP has in mind it will not be useful before Emacs 3X.

Gregory



reply via email to

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