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: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Proposal: Forwards-Compatibility Library for Emacs
Date: Tue, 21 Sep 2021 13:54:03 +0000	[thread overview]
Message-ID: <87bl4mrq4k.fsf@posteo.net> (raw)
In-Reply-To: <AM9PR09MB49770663BDC75F8AFAFF8EBE96A19@AM9PR09MB4977.eurprd09.prod.outlook.com> (Arthur Miller's message of "Tue, 21 Sep 2021 15:37:07 +0200")

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

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>
>>>> 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, ...).
>>>
>>> I think this uncleanliness is a bit risky.  Better put the definitions
>>> in their own namespace.
>>
>> Just to be on the same page, what exactly is the risk? I understand the
>> issue on a gut-level, it goes against convention and recommendations,
>> but the idea is that this package would do that, so that others don't
>> have to.
>
> It is not on a "gut-level" :). I was thinking about same, and wrote you a longer
> answer I just sent. There were no replys when I started, I see now several
> people replied.
>
> There can be two functions defineing slightly different behaviour in different
> version, there can also be 3rd party packages expecting certain behaviour, and
> there is no need to advise too much, say windowing code if application need to
> just check is directory-empty-p.

Yes, I think cases where different versions switch back and forth are
hard to make compatible, so they should be left out of any attempt like
this.

>> Other than that, all the functions and macros are defined first using a
>> "compat--" prefix, then perhaps are aliased to a symbol without a
>> prefix.
>>
>>>  I don't think "transparent compatibility" is
>>> worth the trouble here, and I don't think `s`, `f`, ... solve the
>>> same problem.
>>
>> Of course not, s, f, and the rest of the dash-adjacent ecosystem have
>> different intentions, it is only as a side effect that they provide more
>> functionality than older versions of Emacs do.
>
> They define different API from Emacs, more used by people comming from different
> Lisp(s), clojure if I am correct?

From what I know they are inspired by Clojure and try to provide better
compatibility with the various macros that dash provides (such as
threading), but I am not sure if they are direct translations from
Clojure's standard library.

>> Most of the examples I provide in the file I attached above are simple
>> or slower reimplementations that make programming more convenient, but
>> where "transparent compatibility" becomes interesting is when providing
>> noop compatibility that allows package developers to make use of newer
>> features that are not backwards compatible, such as the additional
>> interactive argument. The infrastructure doesn't exist to handle this
>> information, but package developers will hold back from using these new
>> features because they don't want to abandon all users that aren't on
>> 28.1.
>>
>> I don't see how examples like these could be handled without transparent
>> compatibility.
>
> When it comes to providing newly intoduced functionality, there shouldn't be a
> problem, it should always be possible to just add a function, like
> dired-empty-p:
>
>
> (when (version< emacs-version "28")
>   (defun directory-empty-p (file-name)
>     "Check if a directory contains any other files then dot-files"
>     (when (file-directory-p file-name)
>       (null (directory-files file-name nil
>                              directory-files-no-dot-files-regexp t)))))
>
> You don't even need to advise directory-files for that.

That wouldn't even be advised. My definition

    (compat-defun directory-empty-p (dir)
      "Return t if DIR names an existing directory containing no other files.
    Return nil if DIR does not name a directory, or if there was
    trouble determining whether DIR is a directory or empty.

    Symbolic links to directories count as directories.
    See `file-symlink-p' to distinguish symlinks."
      :version "28.1"
      (and (file-directory-p dir)
           (null (directory-files dir nil directory-files-no-dot-files-regexp t))))

is expanded to

    (progn
      (declare-function compat--directory-empty-p "compat"
                        '(dir))
      (let nil
        (defun compat--directory-empty-p
            (dir)
          "[Compatibility function for `directory-empty-p', defined in Emacs 28.1]\n\nReturn t if DIR names an existing directory containing no other files.\nReturn nil if DIR does not name a directory, or if there was\ntrouble determining whether DIR is a directory or empty.\n\nSymbolic links to directories count as directories.\nSee `file-symlink-p' to distinguish symlinks." nil
          (and
           (file-directory-p dir)
           (null
            (directory-files dir nil directory-files-no-dot-files-regexp t))))
        (compat-ignore
         (defalias 'directory-empty-p #'compat--directory-empty-p))))

which is more or less the same as what you do (setting aside the fact
that on my system, the installation via defalias is ignored).

> But for already existing functions that might lead to problems. I think so at
> least. In the answer I sent you, I was thinking of buffer-local function
> variables instead of advices which are global.

-- 
	Philip Kaludercic



  reply	other threads:[~2021-09-21 13:54 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 [this message]
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
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=87bl4mrq4k.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).