From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Sun, 03 Sep 2023 14:02:50 +0300 Message-ID: <83sf7v7c4l.fsf@gnu.org> References: <834jkca9k0.fsf@gnu.org> <83r0nf98be.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="476"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, emacs-devel@gnu.org, mattiase@acm.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 03 13:04:44 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 1qckuK-000ARt-KH for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Sep 2023 13:04:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcktB-0007nh-06; Sun, 03 Sep 2023 07:03: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 1qckss-0007h8-Pz for emacs-devel@gnu.org; Sun, 03 Sep 2023 07:03:15 -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 1qcksr-0004Zw-IR; Sun, 03 Sep 2023 07:03:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=bD2fw6iR1nAZZ93NhWjzUX02JPhnAdwChiHKbsLszvM=; b=Gb++cH3/FLTV tHQz6yn1J8xe9ou3W+NvM85Brgi+4FKHmeoyYyc8EfEwPYr4T6oPu6mB4kxzUVIQ1DgQhJUZY13kJ 7uAIsKf1wbk0esDZjbF2fc8OY2HwdAoD+pn45EGCA83bW57vrvOAzRn4OsIWcEP+74SYsA6dzVmbt uYbjshdVNVYG3gZ+0WOYsunsxTsFuY1I0/t4FppcZsZ/2IWrij7JOMj2bh1S/r+Ne6w6Ph2mFte7B fsEisDoLR1XtB0FFmRJk4QGXpcMIUElKZUs6Ns8Opc65gP/cTwhGqdjWNL3fqn3UUTXcZ+J+X0mp7 l88/T6xPuk+SOAVKGQAdAQ==; In-Reply-To: (message from Alan Mackenzie on Sun, 3 Sep 2023 10:48:50 +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:309968 Archived-At: > Date: Sun, 3 Sep 2023 10:48:50 +0000 > Cc: stefankangas@gmail.com, emacs-devel@gnu.org, mattiase@acm.org > From: Alan Mackenzie > > > > 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? "Evaluation"? > > > 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. I tend to agree with "the other party", FWIW.