emacs-devel
[Top][All Lists]
Advanced

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

Re: Why shouldn't we have a #if .... #else .... #endif construct in Emac


From: Richard Stallman
Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?
Date: Fri, 08 Sep 2023 20:39:28 -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. ]]]

  > > Or, if you want to keep the condition about the availability of
  > > electric-indent-local-mode, how about keeping the code unchanged

  > >   >   (when (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later.
  > >   >     (electric-indent-local-mode (if c-electric-flag 1 0)))

  > > and inform the byte compiler that (fboundp 'electric-indent-local-mode)
  > > can be optimized based on the Emacs version?  This way you won't need
  > > to change the source code, and we will get the ideal results.

  > I don't know how to do this.  Early on in the thread, Ulrich Müller
  > suggested using

We can make the byte compiler recognize any pattern of code
and treat it specially.  It has two sets of special
patterns: those for inside function definitions (being compiled in
the strict sense of the word), and those for top level.

A pattern for top level could recognize patterns like

   (if (fboundp ...) ...)  and  (if (not (fboundp ...)) ...)

and do whatever the proposed `static-if' function would have done.

Why not?

You spoke of "the additional complexity of the defmacro and defun
macros".  Could you please say concretely what that refers to, because
I don't see it.

  > Originally, I wasn't really thinking about version numbers being the
  > prime use case, but it was easy to use them as an example to get the
  > discussion going.

I think I misunderstood that point, but it's cleared up now.

I am not arguing for or against switching between feature tests
and version tests.  The approach I am suggesting should work for both.


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