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 have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged? Date: Tue, 5 Sep 2023 14:11:06 +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="15581"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ulm@gentoo.org, emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 05 16:12:21 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 1qdWmy-0003rB-Gk for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Sep 2023 16:12:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdWm8-0006cH-4M; Tue, 05 Sep 2023 10:11:28 -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 1qdWm5-0006Zl-S4 for emacs-devel@gnu.org; Tue, 05 Sep 2023 10:11:27 -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 1qdWm1-00060B-OT for emacs-devel@gnu.org; Tue, 05 Sep 2023 10:11:24 -0400 Original-Received: (qmail 6480 invoked by uid 3782); 5 Sep 2023 16:11:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693923068; h=date : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from : from; bh=Cm+bPjCx8EeDHNJB6rsmpYk9sUtCJ6+cVwi9KpriP9o=; b=TpCjCaLRKos5tQq1DWR8MTR2K0J32Acz61pT2UNQ0yfCQ6anuSzDh3CXyLGEPEboXhM3J icLtFR3SZlkVK9vcqZxjhsa1LDJZBOwH4Tny3aaBbW+yRHRniZlskZP9CcIA9hp5iaBT/Ew E6rv6s+eO8hdn/KpAQzHd7JuUhqvP6gAtkr3DlAYR8f6YMwbxu2Gg/kkgkPdYTWygFvNOiX w1dPe9rd+iWWp/qejutfKMVe7elPdDV7zDk1taJehAAmRgmy976YFKoom5ZSTfbBwZJhK85 uZfNmT6TFl2QWitfLkkIwjEguXDUAyKeJdw3XxiC7DoXlX1ZHRBP9JCRxGlA== Original-Received: from acm.muc.de (p4fe150fa.dip0.t-ipconnect.de [79.225.80.250]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 05 Sep 2023 16:11:07 +0200 Original-Received: (qmail 4495 invoked by uid 1000); 5 Sep 2023 14:11:06 -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:310130 Archived-At: Hello, Richard. On Mon, Sep 04, 2023 at 20:30:25 -0400, Richard Stallman wrote: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > How about making the byte compiler recognize the construct > > (if (< emacs-major-version NUMBER) ...) > > and do this optimization on it? > People seem not to have considered this seriously, .... It was actually the first thing I considered when the original problem occurred to me. We have a similar optimisation in place for (featurep xemacs). But then, the number of ways emacs-major-version (to say nothing of emacs-minor-version) can be used is large (starting with <, <=, >, >=, =, /=, eq, eql, equal, and extending to predicates involving e-minor-v), that it would be at least somewhat difficult to apply in practice. > .... but I have not seen any serious discussion of a drawback. I outlined some drawbacks in my post of yesterday evening (Monday 2022-09-04), European time. > What flaw or drawback do people see in it? The above. Plus, some (possibly most) of the predicates we want to optimise out are expressed in terms of present/absent features rather than numeric version numbers. There are just 45 occurrences of emacs-major-version in the Lisp sources, over 2000 occurrences of boundp and fboundp. We could convert (some of) those 45 to use static-if in less time than it would take to amend the interpreter and byte-compiler to handler emacs-major-version specially. > It should optimize the existing the existing code with no change at > all. Isn't that just perfect? Sadly, no it's not. It would only do part of the job which is to be done. It would make some parts of Emacs more complicated. > -- > Dr Richard Stallman (https://stallman.org) > Chief GNUisance of the GNU Project (https://gnu.org) > Founder, Free Software Foundation (https://fsf.org) > Internet Hall-of-Famer (https://internethalloffame.org) -- Alan Mackenzie (Nuremberg, Germany).