unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Arthur Miller <arthur.miller@live.com>
Cc: emacs-devel@gnu.org
Subject: Re: Proposal: Forwards-Compatibility Library for Emacs
Date: Tue, 21 Sep 2021 13:45:19 +0000	[thread overview]
Message-ID: <87fstyrqj4.fsf@posteo.net> (raw)
In-Reply-To: <AM9PR09MB4977863D7E466782EE57C6DF96A19@AM9PR09MB4977.eurprd09.prod.outlook.com> (Arthur Miller's message of "Tue, 21 Sep 2021 15:27:24 +0200")

Arthur Miller <arthur.miller@live.com> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> The idea is to allow developers who don't want to break backwards
>> compatibility to use newer functionality that wasn't provided in older
>> versions of Emacs. This version tries to implement as much as possible
>> from Emacs 24.2 onwards.
>>
>> By its very nature it is an intrusive package, as it defines functions,
>> macros and advice outside of the "namespace", but I don't see any way
>> around that if transparent compatibility is to be provided (anything
>> else would just replicate dash, s, f, ...).
>
> Is there a problem if something replicates something else? :) If it is a good
> thing, we just call it a "design pattern".

Just to clarify: My point is that I *don't* want to just propose a
different dash/s/f/... library, that consists of only a few new useful
functions and macros.

>> As some of the functions are lisp reimplementations of core functions,
>> there exists the risk of a performance overhead. To minimize this, the
>> compatibility layer is only applied necessary: Ideally someone using
>> Emacs 28.1 should have a quasi-empty file, with all the definitions
>> byte-compiled away.
>>
>> Eventually I would like to propose adding something like this to
>> ELPA. It would only makes sense, as more than a few functions were
>> copied verbatim or quasi-verbatim from Emacs itself.
>
> I had a similar idea once, and I think it definitely belongs to an external
> package.
>
> If you had this as an external library, than people who use older Emacs:es could
> install compat-libs as a package, and in cases where there is a compatibility
> function provided, they would just load a compat library after a package is
> loaded.
>
> Say I use dired-empty-p which is introuded in Emacs 28, in "some-program". A user
> of some-program could then:
>
> (with-eval-after-load 'some-program
>   (require 'compat-lib-28))

Why would a user do this?

> I am just a bit concerned about all-in approach. As I udnerstand your code, it is
> loaded as a library, and all code is loaded at once. So there might be code that
> affects files and naming, or they might be coad that affects displayign of
> windows, frames or code of handling user input etc. User might not want to load
> everything and change behaviour of his/her entire Emacs. This might also lead to
> unnexpected problems when there are 3rd party packages that rely on the old
> behaviour.

The audience of this library are developers, not (non-developer)
users. The point is not to make older versions of Emacs work like 28 or
newer, but to make code that targets Emacs 28 work with older versions
(insofar this is possible).

> I would rather prefer if compat-lib-28.el (or whatver called), would check on
> it's features it overloads.
>
> Easy case is wiith named features. It could check if user has loaded dired, and
> load it's compatibility functions for dired that were introuded in emacs 28, and
> it could also put itself in with-eval-after-load statement, so that if some
> feature is loaded again, it loads itself. Harder is case when library does not
> export a named feature, like files.el. 
>
> That would provide for transparent "namespace" handling as you describe in your
> next paragraph.
>
> Of course, newly introduced functions are not the problem; I am concerned with
> already existing functions, which might have changed slightly how they
> function. I don't know if such exists, but I am thinking that some code could be
> broken or still not function, despite function being advised to '28 version'.
>
> I think it is important to not load and advise too much. If a program uses only
> function foo, than there is no need to twinkle with function bar.

I agree, it might make sense to remove some of the compatibility
definitions, that just supply an additional argument. I'd argue there
are cases where it makes sense, such as assoc and the testfn argument,
but they have to be evaluated.

> Another thing I was thinking of is use of advice. Advice is global, it means it
> affects all users of the function. Isn't it better to define a buffer-local
> variable, stash old function in the variable, and than call this buffer-local
> from the compat function. That would also require compat layer to be a minor
> mode, which is why I call it a layer rather than a library. User would have to
> do slightly more:
>
> (with-eval-after-load 'some-program
>   (require 'compat-lib-28)
>   (compat-mode +1))
>
> That way the risk of conflicts when function has slightly change from it's
> previous version is minimized since it will run only in that buffer, affecting
> (hepofully) just 'some-program.
>
> Or something ... I don't know; those were just thoughts, maybe I am wrong about.

A different idea might be to try an integrate the compatibility layer
into the byte-compilation process for specific files. But once again,
this wouldn't be done by the user, but a (package) developer would
request for it to be done.

>> There still is work to be done, before anything could be added to ELPA,
>> especially providing tests to ensure that the compatibility layer is
>> implemented correctly, and making sure that no functions are used that
>> break the compatibility promise.
>
> Ert tests provided in version it provides compatibility for can always be used,
> when there are some? 

I know, I am currently working on writing a test suite with ert.

>> So before I continue working on this, I would like to ask if there is
>> any interest/there are any objections to providing such a library?
>
> Why should there be objections? It is free to write a library and give it to the
> world, right?

Yes, but I respect the opinion of the list and would like to add this to
ELPA, so good objections could change my mind that it is worthwhile to
implement something like this to the end.

-- 
	Philip Kaludercic



  reply	other threads:[~2021-09-21 13:45 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 23:35 Proposal: Forwards-Compatibility Library for Emacs Philip Kaludercic
2021-09-21  0:30 ` Adam Porter
2021-09-21  4:10 ` Lars Ingebrigtsen
2021-09-21  8:28   ` Philip Kaludercic
2021-09-21 12:31 ` Stefan Monnier
2021-09-21 12:40   ` Eli Zaretskii
2021-09-21 12:50     ` Stefan Kangas
2021-09-21 13:38       ` Arthur Miller
2021-09-21 13:49       ` João Távora
2021-09-21 13:00     ` Philip Kaludercic
2021-09-21 13:12       ` Eli Zaretskii
2021-09-21 13:28         ` Philip Kaludercic
2021-09-21 13:24     ` João Távora
2021-09-21 13:29       ` Philip Kaludercic
2021-09-21 13:50         ` João Távora
2021-09-21 14:59     ` Lars Ingebrigtsen
2021-09-21 12:58   ` Philip Kaludercic
2021-09-21 13:37     ` Arthur Miller
2021-09-21 13:54       ` Philip Kaludercic
2021-09-21 14:18         ` Arthur Miller
2021-09-21 15:02   ` Lars Ingebrigtsen
2021-09-21 15:40     ` João Távora
2021-09-21 16:10       ` Philip Kaludercic
2021-09-21 16:22         ` João Távora
2021-09-21 17:22       ` Lars Ingebrigtsen
2021-09-21 17:29         ` João Távora
2021-09-21 19:24     ` Stefan Monnier
2021-09-21 21:06       ` Philip Kaludercic
2021-09-21 21:50         ` Stefan Monnier
2021-09-22  6:48           ` Philip Kaludercic
2021-09-22 17:53             ` Stefan Monnier
2021-09-22 18:54               ` Philip Kaludercic
2021-09-22 19:15                 ` Stefan Monnier
2021-09-21 21:57       ` Lars Ingebrigtsen
2021-09-21 22:08         ` João Távora
2021-09-21 22:16           ` Lars Ingebrigtsen
2021-09-21 22:24             ` João Távora
2021-09-21 22:25               ` Lars Ingebrigtsen
2021-09-21 22:34                 ` João Távora
2021-09-22  6:53           ` Philip Kaludercic
2021-09-22  7:12             ` João Távora
2021-09-22  7:14         ` Arthur Miller
2021-09-21 13:05 ` Philip Kaludercic
2021-09-21 13:27 ` Arthur Miller
2021-09-21 13:45   ` Philip Kaludercic [this message]
2021-09-21 14:05     ` Arthur Miller
2021-09-21 22:17 ` Richard Stallman
2021-09-21 22:24   ` Lars Ingebrigtsen
2021-09-22  9:54     ` Philip Kaludercic
2021-10-04 23:00 ` [ELPA] Add compat.el Philip Kaludercic
2021-10-07  7:03   ` Old (static) builds of Emacs Philip Kaludercic
2021-10-07  7:48     ` Michael Albinus
2021-10-07  7:56       ` Philip Kaludercic
2021-10-07 12:49     ` Stefan Monnier
2021-10-07 20:29       ` Philip Kaludercic
2021-10-07 21:21         ` Stefan Monnier
2021-11-30 21:21     ` Philip Kaludercic
2021-12-01 13:15       ` Stefan Monnier
2021-10-07 20:49   ` [ELPA] Add compat.el Philip Kaludercic
2021-10-08  5:56     ` Eli Zaretskii
2021-10-08  9:59       ` Philip Kaludercic
2021-10-08 11:10         ` Eli Zaretskii
2021-10-08 11:35           ` Philip Kaludercic
2021-10-08  7:45     ` Mattias Engdegård
2021-10-08 10:00       ` Philip Kaludercic
2021-10-15 19:08   ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fstyrqj4.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).