all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregory Heytings via "Emacs development discussions." <emacs-devel@gnu.org>
To: emacs-devel@gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Vasilij Schneidermann <mail@vasilij.de>
Subject: Re: Dealing with obsoletion warnings in non-core code
Date: Tue, 29 Sep 2020 14:11:40 +0000	[thread overview]
Message-ID: <alpine.NEB.2.22.394.2009291558020453.4711@sdf.lonestar.org> (raw)
In-Reply-To: <jwv8scswx26.fsf-monnier+emacs@gnu.org>


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	other threads:[~2020-09-29 14:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 14:35 Dealing with obsoletion warnings in non-core code Vasilij Schneidermann
2020-09-28 17:32 ` Stefan Monnier
2020-09-28 18:16   ` Eli Zaretskii
2020-09-28 18:34     ` Vasilij Schneidermann
2020-09-28 19:00       ` Eli Zaretskii
2020-09-28 19:24     ` Stefan Monnier
2020-09-29 14:07       ` Eli Zaretskii
2020-09-29  8:21 ` Gregory Heytings via Emacs development discussions.
2020-09-29  8:28   ` Gregory Heytings via Emacs development discussions.
2020-09-29  9:33     ` Gregory Heytings via Emacs development discussions.
2020-09-29 13:11   ` Stefan Monnier
2020-09-29 14:11     ` Gregory Heytings via Emacs development discussions. [this message]
2020-09-29 14:46       ` Stefan Monnier
2020-09-29 15:36         ` Gregory Heytings via Emacs development discussions.
2020-09-29 14:55     ` T.V Raman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.NEB.2.22.394.2009291558020453.4711@sdf.lonestar.org \
    --to=emacs-devel@gnu.org \
    --cc=ghe@sdf.org \
    --cc=mail@vasilij.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.