all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: "J.P." <jp@neverwas.me>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	 emacs-devel <emacs-devel@gnu.org>,
	 Amin Bandali <bandali@gnu.org>,
	 emacs-erc@gnu.org
Subject: Re: Adding 'compat' from ELPA as an optional dependency to ERC
Date: Mon, 25 Jul 2022 18:56:39 +0000	[thread overview]
Message-ID: <87bktddnrs.fsf@posteo.net> (raw)
In-Reply-To: <871qugu3y3.fsf@neverwas.me> (J. P.'s message of "Tue, 19 Jul 2022 15:34:44 -0700")

"J.P." <jp@neverwas.me> writes:

> Hi Philip (and Stefan),
>
> Philip Kaludercic <philipk@posteo.net> writes:
>
>>                                             By explicitly loading
>> compat-28, one would additionally load "prefixed" definitions for
>> functions that add new features to existing functions.
>>
>> E.g. consider how assoc acquired a new optional argument "TESTFN" in
>> version 26.  One would either have to advise the existing function,
>> which was regarded to be too invasive and dangerous, or to define a
>> separate function underneath the `compat-' prefix -- `compat-assoc'.
>>
>> This function is not made visible by loading `compat', and explicitly
>> ought not to be in this case, as someone using the in-tree version of
>> ERC would not have no such function defined.  In this sense the support
>> compat can provide for core packages is limited, but as it seems for
>> ERC's requirements sufficient.
>
> I suppose we could always add prefixed definitions down the road if
> really needed, perhaps to spare us from having to copy some complicated
> backport definition in full. 

There is always the possibility of changing compat to advise certain
functions instead of providing prefixed alternatives.  But that should
probably be decided in a case-by-case basis.

Depending on the interest of the Emacs maintainers in `compat' as a
project, it might also be possible to add compat-* definitions to the
core, thought I am not certain sure how fond I am of this idea.

>                              
>                              Although, I believe doing so would also
> define compat- prefixed variants in all versions of Emacs, the idea
> being to save third-party packages from having to do stuff like
>
>   (defmacro erc-compat--json-parse-string (string &rest args)
>     `(,(if (fboundp 'compat-json-parse-string)
>            'compat-json-parse-string
>          'json-parse-string)
>       ,string
>       ,@args))

If a function like this were to be definied upstream

        (defun get-compatibility-func (name)
          "Return the function NAME of a compatibility alias."
          (let* ((compat (intern-soft (format "compat-%s" name))))
            (or (symbol-function (if (fboundp name) name compat))
                (error "No definition for %S could be found" name))))

then all that ERC would have to do is

        (defalias 'erc-json-parse-string
          (get-compatibility-func 'json-parse-string))

> But in ERC's case, there'd be no avoiding this kind of indirection.
> (Please correct me if that's a flawed understanding.)

While prefixing is used, no, because we cannot assume that compat is
installed.



  reply	other threads:[~2022-07-25 18:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 14:43 Adding 'compat' from ELPA as an optional dependency to ERC F. Jason Park
2022-07-19 16:17 ` Stefan Monnier
2022-07-19 16:25   ` Philip Kaludercic
2022-07-19 22:34     ` J.P.
2022-07-25 18:56       ` Philip Kaludercic [this message]
2022-07-26  3:04         ` J.P.
2022-07-26 15:17           ` Philip Kaludercic
2022-07-27 12:55             ` J.P.
2022-07-26 21:00         ` Copying autoloads (was: Adding 'compat' from ELPA as an optional dependency to ERC) Stefan Monnier
2022-07-26 23:00           ` Copying autoloads 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

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

  git send-email \
    --in-reply-to=87bktddnrs.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=bandali@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-erc@gnu.org \
    --cc=jp@neverwas.me \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.