From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Tue, 05 Sep 2023 20:58:38 -0400 Message-ID: References: Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27742"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ulm@gentoo.org, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 06 02:59:34 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 1qdgtI-0006zO-Np for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Sep 2023 02:59:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdgsU-0006zV-JX; Tue, 05 Sep 2023 20:58:42 -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 1qdgsR-0006zB-Nx for emacs-devel@gnu.org; Tue, 05 Sep 2023 20:58:39 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdgsR-0008GS-36; Tue, 05 Sep 2023 20:58:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=F4SNCE5bIYifzEowx7POK45+y7/YB0PyGA5y8PqUFFs=; b=J6RIse0CNkt2 +XOONV6kyjnXHrCZqVLc9ZvgCixtu9DR31tvQqbQcEHYRDauI4m2VKK9Haw9nnG4/+xXyozsz3J8N /KUjAmuLBGBDUGTCWmPm6OH4vdKd8+6Wu0HqAViCDmqETOJAlrlixlpZhud2E/mnpBmikIfJ5BQ9S FHaK7S4u82P41KkBXijkueSDyC2Y0Xm5txWiwfQF5G9euEWdCGdWWORIlfLK4jUW6HIXNEBp6AMCg xeMGspIXglWfOy187vN6ybo/k/WBHT2NiF1zbLjSIgZQv6x7dcVeBIkrhJbkrX9pT316VKwlJOeOu QBXqqvyEv7zqOJKX1mj9yg==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1qdgsQ-0000iT-8p; Tue, 05 Sep 2023 20:58:38 -0400 In-Reply-To: (message from Alan Mackenzie on Mon, 4 Sep 2023 10:50:07 +0000) 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:310161 Archived-At: [[[ 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. ]]] > For example, in CC Mode there is a chunk of code looking like .... > (when (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later. > (electric-indent-local-mode (if c-electric-flag 1 0))) > , and there are quite a few instances like it. Here, there is a comment > about which versions are relevant, but that is somewhat unusual. Note > here that we would have to test both the major and minor version numbers > to do this correctly. > I intend to replace that code with > (static-if (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later. > (electric-indent-local-mode (if c-electric-flag 1 0))) > .. (hash-if has been renamed static-if.) It would be more work to > replace it with > (when (or (> emacs-major-version 24) > (and (= emacs-major-version 24) > (>= emacs-minor-version 4))) > (electric-indent-local-mode (if c-electric-flag 1 0))) If you want to have a conditional about version mumbers, I think that is the right way to write it. Or, if you want to keep the condition about the availability of electric-indent-local-mode, how about keeping the code unchanged > (when (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later. > (electric-indent-local-mode (if c-electric-flag 1 0))) and inform the byte compiler that (fboundp 'electric-indent-local-mode) can be optimized based on the Emacs cersion? This way you won't need to change the source code, and we will get the ideal results, > static-if is a completely ordinary macro which is 10 lines long > (including doc string), and there's a new section in the elisp manual for > it. I think the simplicity of the source code as it will be counts for more than the simplicity of a new macro which, with my approach, we don't need o add. -- 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)