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: Tue, 05 Sep 2023 20:58:38 -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. ]]]

  > For example, in CC Mode there is a chunk of code looking like ....

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

  > , and there are quite a few instances like it.  Here, there is a comment
  > about which versions are relevant, but that is somewhat unusual.  Note
  > here that we would have to test both the major and minor version numbers
  > to do this correctly.

  > I intend to replace that code with

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

  > ..  (hash-if has been renamed static-if.)  It would be more work to
  > replace it with

  >   (when (or (> emacs-major-version 24)
  >             (and (= emacs-major-version 24)
  >              (>= emacs-minor-version 4)))
  >     (electric-indent-local-mode (if c-electric-flag 1 0)))

If you want to have a conditional about version mumbers,
I think that is the right way to write it.

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 cersion?  This way you won't need
to change the source code, and we will get the ideal results,

  > static-if is a completely ordinary macro which is 10 lines long
  > (including doc string), and there's a new section in the elisp manual for
  > it.

I think the simplicity of the source code as it will be
counts for more than the simplicity of a new macro
which, with my approach, we don't need o add.







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