From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Wed, 30 Aug 2023 10:31:40 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32787"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 30 12:32:53 2023 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 1qbIVH-0008Gn-Qn for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Aug 2023 12:32:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbIUR-0005oO-LV; Wed, 30 Aug 2023 06:31:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbIUO-0005n1-KG for emacs-devel@gnu.org; Wed, 30 Aug 2023 06:31:57 -0400 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbIUL-0003Xg-S1 for emacs-devel@gnu.org; Wed, 30 Aug 2023 06:31:56 -0400 Original-Received: (qmail 24756 invoked by uid 3782); 30 Aug 2023 12:31:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693391501; h=date : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from : from; bh=5rBVjwqKpaXhI84YC+IEyqN0q98zfDzLzqOn5KoBgF4=; b=rfRVxg6UUu/RdgiWLlV0cjiWFqsy7LgBXEEtR6RJPFHJt4/ESIWWy9cL0iUfcGoP317s1 ysM/MgTQD9FHTl31RvMKz1pBF0yye0/ipDk8qtcPD2xHg1DmbzRna8tE9mjcBy5qALDxbK/ 38I9PawFNhzV4LFMRfjY7Vjjve5wgwFcUJ4bmLiCZkGwGE9QgR/7ic2dEp8kbAi7wn8bdwJ XIEGAUDGk0uFnbYFiMkfeLTRoOqEK/YFEycmjSx3tnZZoIYxgbQYhqJJZzOWhITsJJCD3fS u1oFA39GTXSiuLkIdSsTogofi9OyowghWutc4Ntpy6vc4Ik1vCjNQeHLMcSw== Original-Received: from acm.muc.de (pd953a1ec.dip0.t-ipconnect.de [217.83.161.236]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 30 Aug 2023 12:31:40 +0200 Original-Received: (qmail 6491 invoked by uid 1000); 30 Aug 2023 10:31:40 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:309539 Archived-At: Hello, Stefan. On Tue, Aug 29, 2023 at 22:09:25 +0200, Stefan Kangas wrote: > Alan Mackenzie writes: > > What do people think about this? > I have two questions: > 1. Would it be hard to make the byte-compiler not warn in the > situation you describe? (That situation being where an obsolete function/variable is tested for, and is used or not used according to the result of the test.) It would not be too hard, and the scheme I'm proposing (with help from Philip K.) is one way of doing this. I'm sure there are other possible ways, too. > 2. Isn't something like this enough to silence the byte-compiler? > (defalias 'foo-defadvice > (if (< emacs-major-version 24) > 'defadvice > (lambda () (message "foo")))) > (foo-defadvice) It may be, but it's clumsy. We would need such an alias for _each_ function/variable which has been declared obsolete. In my proposed mechanism, by contrast, one would just need to replace an `if' form by a `hash-if'. -- Alan Mackenzie (Nuremberg, Germany).