|
From: | Adam Porter |
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 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 |
> 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.
[Prev in Thread] | Current Thread | [Next in Thread] |