From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter 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 06:06:54 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8909"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Cc: acm@muc.de, emacs-devel@gnu.org, ulm@gentoo.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 05 13:08:03 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 1qdTub-00023O-NY for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Sep 2023 13:08:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdTth-0001B0-MC; Tue, 05 Sep 2023 07:07:05 -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 1qdTtf-00019t-7U for emacs-devel@gnu.org; Tue, 05 Sep 2023 07:07:03 -0400 Original-Received: from dormouse.elm.relay.mailchannels.net ([23.83.212.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdTtc-0001ra-Dl; Tue, 05 Sep 2023 07:07:02 -0400 X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 78E2C80B6A; Tue, 5 Sep 2023 11:06:57 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a311.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F06BC8057B; Tue, 5 Sep 2023 11:06:56 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1693912017; a=rsa-sha256; cv=none; b=cVPLPJCe+WxwWB0Bl9fEjnwX3jx84EQ+LBO4d/SGjAZotxy8tQ5AtPqhLckbQqlXBvZWKh x4ws4RddK3cZMh5SZvE/sjvF5fdsn9IBILt2UqBJXFjiSbWOBuZd5T5/uZB7r1qY84JNth JozlZ2DUKIXxDwejFxJntyQUTau51uX9IwdKYbjUbB54kAXswiSr6C6BF6tM7KFIVHUb0R oEnWWw4gwvcHQV5YbPBFc09ooiSGVpH3IAc7aTtoIDuHAMGPt/DnWIlk2uY6Nq+CVKD3gu vxAUDoxTcsn42+B5BImjEoYKhj3EM7vMOEuH5gYinfHYTF2j9Z22MTbN6R8oGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1693912017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nLG8GkaokF6yrTPEW7Kg8R6FtBxYpsO3AIBshQo0qz8=; b=rLmG2J8eYdrcIzyucbCnTB+0E4Z6mlF7Bgwfq66VuKiIXWfyUMtsYyQR4G0otllZwjKW51 2ehqb0jcZgT145S7kGbx1G9wQIWkwfQC1pgxgAydNfxCi1YZMd5nuJAktMomPgAaKXWhCP RFPnFTxFmyJ2Cysr3bhWGvNAntE3WHQdf4Q5TxcbN63GEBD7vDUowqqZyz8/1qlGJgMFMy tg4cyuxIaCVtv3vv40IHmtp9F/Rs8zq5yACcr8REDQNLUyvrnvSABdNQGa11rPjwOJKpuB BoKKO+Vzfs5zdadYgQ2gLwjznTvQWZ3jU/Lr6WXTgxrO3B6WMn33iOZHe3mjjg== ARC-Authentication-Results: i=1; rspamd-6fd95854bb-2ddvb; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|adam@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Trouble-Whistle: 75a19ab1672eb71b_1693912017227_1973888323 X-MC-Loop-Signature: 1693912017227:1393271833 X-MC-Ingress-Time: 1693912017227 Original-Received: from pdx1-sub0-mail-a311.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.120.143.185 (trex/6.9.1); Tue, 05 Sep 2023 11:06:57 +0000 Original-Received: from [10.43.3.210] (unknown [193.56.116.15]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adam@alphapapa.net) by pdx1-sub0-mail-a311.dreamhost.com (Postfix) with ESMTPSA id 4Rg2l41whFz6H; Tue, 5 Sep 2023 04:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1693912016; bh=nLG8GkaokF6yrTPEW7Kg8R6FtBxYpsO3AIBshQo0qz8=; h=Date:To:Cc:Subject:From:Content-Type:Content-Transfer-Encoding; b=SrAoqDHwO0hbOnHNYjSSaiDDFzS4SH2URJxwakAa1TCnNKukKaZYxn/KKzocbxwLT AAeqLs9s8YzWjmCEQdbswYnH08qn5RYLoTrdhlJ3PHvN3LRAmYzfI395PoV21e4BSd xlsPAo/zDBe1YLtvm7aO5mkTdob8u8tkF57SG3XeRbKUe4VnjF3gAP72Gk9ibK+zdk pa4ALcIbl/VBm6RgTv+I0hcLh7Osbmmhb3d8x/MlpQShQMTibpF2hAo+bNVtbC6Ce8 LTi9ou+2aMs1DCbfm7nOr2LUkawSy/5XmIvnv/cFo6jgeTuy23LbktnT3UFo+kExj6 ooPobhblhETGA== Content-Language: en-US In-Reply-To: Received-SPF: neutral client-ip=23.83.212.50; envelope-from=adam@alphapapa.net; helo=dormouse.elm.relay.mailchannels.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, NICE_REPLY_A=-1.473, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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:310125 Archived-At: > > 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, but I have not seen > any serious discussion of a drawback. What flaw or drawback do people > see in it? It should optimize the existing the existing code with no > change at all. Isn't that just perfect? Maybe I'm misunderstanding something, but while that idea does seem elegant, a potential drawback of that idea would seem to be that byte-compiled code would need to be recompiled when the user's Emacs version changed in a relevant way, while checking at runtime would mean that it would always behave correctly. It's my impression that most Emacs users don't know about byte-compiling packages, so when encountering such a problem, most of them wouldn't know to "M-x package-recompile" to try to solve it. They'd probably end up posting a message somewhere asking for help, or even making a false bug report to a package author. Having said that, am I wrong in thinking that this STATIC-IF suggestion would suffer from the same problem? Here's the scenario I'm imagining: 1. User is running Emacs vN. 2. User installs package P at vM. 3. Emacs vN+1 is released. 4. Package P is updated to conditionally use features from Emacs vN+1, and the package is released at vM+1. 5. User installs package P at vM+1 while still using Emacs vN. The package is byte-compiled for Emacs vN and so compiles out the optional support for features available on Emacs vN+1. 6. User upgrades Emacs to vN+1 and starts it. 7. User expects package P's support for the new features to be available, but it's not, and there's no apparent reason why. 8. User files a bug report on package P. 9. Package P's author is confused and asks the user to reinstall the package. 10. User does so and it works. Everyone shrugs. 11. At some later date, the package author realizes what happened, perhaps from reading a thread on emacs-devel, and the next time a user reports the same problem (likely to happen for a year or two, given how long Emacs versions remain in use), he tells the user to "M-x package-recompile" it. Again, maybe I'm missing something obvious, but that scenario seems very likely to me, so I'm not sure that byte-compiling features conditionally on the version of Emacs used to compile the file is a great idea. Runtime checks seem much more robust.