From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.erc.general,gmane.emacs.devel Subject: Re: Adding 'compat' from ELPA as an optional dependency to ERC Date: Mon, 25 Jul 2022 18:56:39 +0000 Message-ID: <87bktddnrs.fsf@posteo.net> References: <87fsixw4co.fsf@neverwas.me> <87edyhrrw0.fsf@posteo.net> <871qugu3y3.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17665"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel , Amin Bandali , emacs-erc@gnu.org To: "J.P." Original-X-From: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Mon Jul 25 20:57:20 2022 Return-path: Envelope-to: sf-erc-help@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oG3GY-0004Lp-Ih for sf-erc-help@m.gmane-mx.org; Mon, 25 Jul 2022 20:57:18 +0200 Original-Received: from localhost ([::1]:51238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oG3GX-0000s5-59 for sf-erc-help@m.gmane-mx.org; Mon, 25 Jul 2022 14:57:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oG3G9-0000qy-T1 for emacs-erc@gnu.org; Mon, 25 Jul 2022 14:56:54 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:53419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oG3G7-0003Xx-IL for emacs-erc@gnu.org; Mon, 25 Jul 2022 14:56:53 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id C5E2F240029 for ; Mon, 25 Jul 2022 20:56:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1658775407; bh=sFU1y0wkSZ0LK0Suzia7suqSaif1mKuyI/krRCngI6s=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=l/Tr17bOQrgBp/1mzksqSooa4DXF9rmcePdDNgZYe2Nc40QDmjFFhSBuCOWrSV0uM FmEOfy2EisbXronJ5QA0YttmtYryiFib79K2MqDLZX27xrRE7+3iCv19lj8+Q8dxlY CxnbGHNwYltuD63PVrxkuUMwaKJ19Bjr0Mn94aHQbRpDgGlTj+l84Hn4TcDantnxfa 7edm9c4viLj9mM/D3FGc1bojGVW96C2ODNGeqg1MqqlUa+PYytlX5PsuetfjBZTkyt rMMnbViEFafYsMs04Q7d46Fy/q5eoBfwZ76gk7ZMESiY74+9a2SuQvOzvZlN/s8qaA h2b+QAYL6iN/g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ls8R22VxYz6tn9; Mon, 25 Jul 2022 20:56:46 +0200 (CEST) In-Reply-To: <871qugu3y3.fsf@neverwas.me> (J. P.'s message of "Tue, 19 Jul 2022 15:34:44 -0700") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-erc@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General discussion about ERC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Original-Sender: "emacs-erc" Xref: news.gmane.io gmane.emacs.erc.general:1885 gmane.emacs.devel:292648 Archived-At: "J.P." writes: > Hi Philip (and Stefan), > > Philip Kaludercic 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.