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: Sun, 3 Sep 2023 10:48:50 +0000 Message-ID: References: <834jkca9k0.fsf@gnu.org> <83r0nf98be.fsf@gnu.org> 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="2073"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, emacs-devel@gnu.org, mattiase@acm.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 03 12:49:19 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 1qckfO-0000Km-OK for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Sep 2023 12:49:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qckf6-0001Cw-D7; Sun, 03 Sep 2023 06:49:00 -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 1qckf3-0001CX-RX for emacs-devel@gnu.org; Sun, 03 Sep 2023 06:48:58 -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 1qckf0-0000YW-P9 for emacs-devel@gnu.org; Sun, 03 Sep 2023 06:48:57 -0400 Original-Received: (qmail 94665 invoked by uid 3782); 3 Sep 2023 12:48:52 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693738132; h=date : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from : from; bh=LhG9rVEGySPttNtqOPDF2RlLk2C7nnl4uSF/VNPm5dY=; b=f7q2aPoLIE5QwUWQ2VQCrOek8vjXMF3u90oA34rEukKmevj8SUJ5i1dFGH/BzL73bNUg/ cdmz3CCnRf1ln+D7OSX2GNSgklrOd2VFL9rGqjafeX7xvOzXMbkduVzBXKC46Ey4ZCUOYhn EiHxSEu/7C56sq2lQ9n5/44f8TE/EN9TZUvU+t54QKgQmkJGZy7BVKlgzY+RFdPMht8XjhR 8lcyI3FyoW+rj5ENdJ5gBz9QXiELLZj1guHmZ1poCRVuVB6KVzKyROEtwvoIi00RYeYbd4k E8Ql4shh5gPL3tQkWHWA2+YkTPMXX6kZFILGJK5aPyyh70wDcRh288s3mGZA== Original-Received: from acm.muc.de (p4fe157eb.dip0.t-ipconnect.de [79.225.87.235]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 03 Sep 2023 12:48:50 +0200 Original-Received: (qmail 4695 invoked by uid 1000); 3 Sep 2023 10:48:50 -0000 Content-Disposition: inline In-Reply-To: <83r0nf98be.fsf@gnu.org> 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:309966 Archived-At: Hello, Eli. On Sun, Sep 03, 2023 at 07:42:13 +0300, Eli Zaretskii wrote: > > Date: Sat, 2 Sep 2023 19:43:29 +0000 > > Cc: stefankangas@gmail.com, emacs-devel@gnu.org, mattiase@acm.org > > From: Alan Mackenzie > > > > ++++ > > > > +** There is now conditional compilation, based on the C language's #if. > > > > +To use this, see the new macro 'static-if'. > > > Same here. Here, it is actually worse: "based on C language's #if" > > > could be misinterpreted as meaning the implementation is based on #if > > > in some way. I would suggest the following text in NEWS: > > > ** New macro 'static-if' for conditional byte-compilation of code. > > > This macro hides a form from the byte-compiler based on a > > > compile-time condition. This is handy for avoiding byte-compilation > > > warnings about code that will never actually run under some > > > conditions. > > static-if actually works for interpreted compilation as well as byte > > compilation, so I've removed two "byte-"s from your text, leaving: > > +++ > > ** New macro 'static-if' for conditional compilation of code. > > This macro hides a form from the compiler based on a compile-time > > condition. This is handy for avoiding byte-compilation warnings about > > code that will never actually run under some conditions. > What is "interpreted compilation" in Emacs? I'm aware of only two > compilers in Emacs: the byte compiler and the native compiler. So > when you talk about "the compiler" above, what does that allude to? I mean the defmacro and defun macros, particularly when invoked by C-M-x, etc. Do we have a generic term for these, regardless of whether they are called interpretatively or in the context of byte/native compilation? > > I think it's now ready to commit, except .... > > I've had some private email which suggested that perhaps static-if > > should not include the condition-case which copes with an ancient eval > > from before lexical binding. I can see some merit in the argument > > (lexical binding happened in 24.1, I think), but on the other hand, that > > extreme backwards compatibility doesn't really cost us anything > > (static-if is just 13 lines of code). > > What do you think? > I don't think I understand the issue: it was discussed in private > email , and you didn't tell enough for me to understand and form an > opinion. What do you mean by "condition-case which copes with an > ancient eval from before lexical binding"? Sorry. The idea is that package maintainers can copy the source of static-if directly into their packages so as to be able to use it in older Emacsen. In the code for static-if, there's a call to eval with two arguments, CONDITION and lexical-binding. In (very) old versions of Emacs, eval would only accept one argument, the form. So in such an old Emacs, static-if will throw a wrong-number-of-args (or void-variable) error. I have proposed catching this error with a condition-case and in the handler, calling eval again with just one argument. The other party in the email has opined that static-if should not contain this condition-case mechanism, and anybody writing for such an old Emacs should make their own adjustments. Perhaps it's too small a point to be worth bothering about, but I thought I'd ask your view anyway. -- Alan Mackenzie (Nuremberg, Germany).