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: Thu, 31 Aug 2023 07:50:23 +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="6997"; 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 Thu Aug 31 09:51:48 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 1qbcSy-0001e4-HH for ged-emacs-devel@m.gmane-mx.org; Thu, 31 Aug 2023 09:51:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbcRm-00014R-2k; Thu, 31 Aug 2023 03:50:34 -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 1qbcRk-00014I-Sx for emacs-devel@gnu.org; Thu, 31 Aug 2023 03:50:32 -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 1qbcRf-00012s-U7 for emacs-devel@gnu.org; Thu, 31 Aug 2023 03:50:32 -0400 Original-Received: (qmail 24126 invoked by uid 3782); 31 Aug 2023 09:50:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693468225; h=date : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from : from; bh=EhU8+VIkWcAXxgOd3tsqmEbVqpyZ6t3Qh6GX80wOG/8=; b=hH7d36L6yXoJBbXQO9PpD2Nz8t4Q1QJIQhRqJI/ey0Zv6mvyzjmm/KCV01brFBJlXYsU7 ndd47iQFQhuofcrUXvf9ItyyRowxMPX7bSfU/WhwxBJxzUNEG8Ch+HE9KxzA7WtS3U6/2sm cpUoTpQHcCnkZZXeT7svczGFsrjnZjkwzqu69phFqlzfgzpXbKILKaaSgw3sjqK/rkpOLia PipO3Pp9CtkTpQEtwJNIz+ZbwpjHTtobzG5t4IvRoQZo0ghLz7hDvdEgNQme1rhL0rSer8c 59aRvYkcfi9UG5W1s8PeVQ3QunTvpKa+XuKuFS4M9IdBy4TGzr64mENhOtcA== Original-Received: from acm.muc.de (p4fe15975.dip0.t-ipconnect.de [79.225.89.117]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 31 Aug 2023 09:50:23 +0200 Original-Received: (qmail 15473 invoked by uid 1000); 31 Aug 2023 07:50:23 -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=unavailable 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:309604 Archived-At: Hello, Richard. On Wed, Aug 30, 2023 at 22:07:04 -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. ]]] > > > (when (eval-when-compile (< emacs-major-version 24)) > > > (defadvice .....)) > > However, when evaluating the containing defun/defmacro rather than byte > > compiling it, the irritating warning message will appear with the e-w-c > > strategem, but not with hash-if. ;-) > How about making the byte compiler recognize the construct > (if (< emacs-major-version NUMBER) ...) > and do this optimization on it? > I think that will DTRT when compiled and when interpreted, > and it won't require changes in the code of the programs that use it. The conditions we want to test are sometimes/frequently expressed in terms of the (non-)existence of variables, etc. It would be inconvenient for package maintainers to have to determine "critical" Emacs version numbers to use. Also, it is possible for the condition to be dependent upon a minor version number, maybe. Why do you think a more restricted test of the version number would be better than a more general test? The changes to the code to convert from `if' to `hash-if' (or `static-if' as has been proposed) are minor - they just need amending the if/when/unless forms to hash-if. Also, there will not be all that many of them. That way, we have more flexibility than testing just the major version number. > That will handle `when' and `unless', since they expand into `if'. > It may be necessary to implement this in two places, one for inside of > function bodies and one for top level (outside of function > definitions). But the code for this should be so short that having > two is hardly much loss. The macro hash-if itself is very short, the current version taking 13 lines (including doc string), including a condition-case checking for `eval' having only one parameter. The idea is that a package maintainer can copy this directly into her source code (inside an (if (not (fboundp 'hash-if)) ....)) so the mechanism will work also in older Emacsen. > -- > 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).