From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Dealing with obsoletion warnings in non-core code Date: Mon, 28 Sep 2020 13:32:47 -0400 Message-ID: References: <20200928143540.GB1002@odonien.localdomain> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25697"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 28 19:59:45 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 1kMxRB-0006XA-1g for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 19:59:45 +0200 Original-Received: from localhost ([::1]:54782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMxRA-0003eX-04 for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 13:59:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMx1B-0007he-CR for emacs-devel@gnu.org; Mon, 28 Sep 2020 13:32:54 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:42190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMx18-000055-Qi for emacs-devel@gnu.org; Mon, 28 Sep 2020 13:32:52 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A7012441332; Mon, 28 Sep 2020 13:32:49 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 579D144132E; Mon, 28 Sep 2020 13:32:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1601314368; bh=7+zjkSEj7rSnyjYcrt1K65mbh5YzFJanhVrXTCHt0k4=; h=From:To:Subject:References:Date:In-Reply-To:From; b=mpgP6z5sOyvuUg7MqmfYT+h4bK0SvAlPFsLLS/We6a8Xjv7BJ7GNhRG3BPaQVZdoz g1iNgCRKhDwV0NUxpfTxlNm+AqwZmIO20AT8ICm4lQ1OwQg/Dptwcu117VqZY2CBCG I6ZI92ozkhw818+B5mikrAmYHvHhPP+cOgwDCtQKQowN7Zm/lRp0vJ6WwsoN5eLITk EvKPMFafkVnq+PCYjZSurwGqLUy+IjomouEVc/QWur/093O9cRsJoA4fiiq2GAPWBk p9fMbjQwBoXsgCOAs4SmbvOFt82A5Yn6VDOZRQCcUTIliWlWhwKCnAoHVAV84pJW7c B8BmXuvTaGmow== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3B2A41203EF; Mon, 28 Sep 2020 13:32:48 -0400 (EDT) In-Reply-To: <20200928143540.GB1002@odonien.localdomain> (Vasilij Schneidermann's message of "Mon, 28 Sep 2020 16:35:40 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/28 12:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=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:256627 Archived-At: > 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