emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when


From: Richard Stallman
Subject: Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?
Date: Thu, 07 Sep 2023 21:01:04 -0400

[[[ 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. ]]]

If you want to convert most of the existing version conditions to
feature tests, in general I don't object.

But there is one thing to watch out for: in each instance, it can
happen that a feature test is kludgy and a version test is cleaner.
It can also happen that a version test is kludgy and a feature test is
cleaner.  So it could happen that, after converting 40 version tests
to feature tests that are natural, there will be 5 remaining version
tests that are better left as version tests.

Or there might be 10 such, or none such.  It might be better to leave
a few of them as version tests while converting the rest.

Optimizing these tests to operate at compile time is a separate issue.
Please DON'T introduce a new construct `static-if' -- instead please
make the compiler optimize the constructs that are already in the
code.

That can be done for feature tests, or for version tests, or for both.
It won't be difficult.

Why link these two issues?  Your last message still presumes using
`static-if' but it shows no advantage in that choice.  For instance,

  > It was actually the first thing I considered when the original problem
  > occurred to me.  We have a similar optimisation in place for (featurep
  > xemacs).  But then, the number of ways emacs-major-version (to say
  > nothing of emacs-minor-version) can be used is large (starting with <,
  > <=, >, >=, =, /=, eq, eql, equal, and extending to predicates involving
  > e-minor-v), that it would be at least somewhat difficult to apply in
  > practice.

I don't see an argument there for `static-if' instead of handling `if'
at compile time (assuming the actual conditional is the same either way,
which it can be).  Likewise, here

  >   We could convert (some of) those 45 to use static-if in
  > less time than it would take to amend the interpreter and byte-compiler
  > to handler emacs-major-version specially.

Maybe so, but the latter would be cleaner.  Also, if some if those 45
are converted to feature tests, this issue will be smaller, If only 5
version tests remain, the number of ways such tests are expressed will
be at most 5, and they could easily be reduced to 1 or 2.





-- 
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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]