From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: Dealing with obsoletion warnings in non-core code Date: Tue, 29 Sep 2020 14:11:40 +0000 Message-ID: References: <20200928143540.GB1002@odonien.localdomain> Reply-To: Gregory Heytings Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Alpine 2.22 (NEB 394 2020-01-19) Cc: Stefan Monnier , Vasilij Schneidermann To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 29 16:14:39 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNGOs-000180-2R for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Sep 2020 16:14:38 +0200 Original-Received: from localhost ([::1]:52292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNGOr-0004JU-2R for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Sep 2020 10:14:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNGMB-000196-1Y for emacs-devel@gnu.org; Tue, 29 Sep 2020 10:11:51 -0400 Original-Received: from mx.sdf.org ([205.166.94.24]:52528) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNGM8-0006CS-81 for emacs-devel@gnu.org; Tue, 29 Sep 2020 10:11:50 -0400 Original-Received: from sdf.org (IDENT:ghe@otaku.sdf.org [205.166.94.8]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 08TEBg5p012763 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Tue, 29 Sep 2020 14:11:43 GMT Original-Received: (from ghe@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 08TEBxfG018095; Tue, 29 Sep 2020 14:11:59 GMT In-Reply-To: Received-SPF: pass client-ip=205.166.94.24; envelope-from=ghe@sdf.org; helo=mx.sdf.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/29 10:11:45 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:256698 Archived-At: 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