Subject: bug#66554: [PATCH] Add the public API of Compat to the core

From: Daniel Mendler <[email-masked]>
Date: Fri, 19 Jan 2024 07:42:57 +0100

Stefan Kangas <[email-masked]> writes:

> Daniel Mendler <[email-masked]> writes:
>
>>> If you want to label the `most-positive-fixnum` as a hack, I guess
>>> that's OK but then the comment should clarify what it's referring to.
>>
>> I may be wrong, but I assume that Philip considers the autoload a hack.
>> In this thread we discussed various alternatives to approach this
>> problem, e.g., the package version regexp (another hack), or my naive
>> idea of simply writing 29.1.9999 in the compat.el package header (yet
>> another hack).
>
> IMHO, the "naive" (why naive?) number 9999 is more readable, and in
> practice will be the same as using most-positive-fixnum.  So I'd just
> use that.

The number 9999 is of course more than large enough. What I meant here -
not the choice of the number is what one may consider a hack, but the
way we register the version of the builtin compat.el package. There were
multiple ways which have been discussed in this thread:

- Write the package version of compat.el directly in the header. This
  was my first proposal. This is not ideal since it requires the
  maintainer to update the header whenever a new version of Emacs is
  released. Therefore naive.

- Stefan Monnier proposed to instead use an autoload and to dynamically
  "compute" and register the builtin compat.el version. I consider this
  a clever trick. It is maybe a bit unconventional to register builtin
  package versions like this, but it will work perfectly well and
  doesn't require any intervention. There is no risk that one can forget
  to update the package header.

If we register (emacs-major-version emacs-minor-version 9999),
(emacs-major-version emacs-minor-version most-positive-fixnum) or
(emacs-major-version emacs-minor-version 1.0e+INF) will not make any
difference in practice. As long as the number is large enough, it will
work.

We should still keep the reader of the code in mind, who may wonder
about the magic number and about the special package version
registration, so a comment is certainly justified. Philip did include
such an explanation in his patch. We should only replace the word "Hack"
with "Clever trick" in the comment.

Daniel