From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Proposal: Forwards-Compatibility Library for Emacs Date: Tue, 21 Sep 2021 16:18:25 +0200 Message-ID: References: <877dfavmzw.fsf@posteo.net> <875yuut79f.fsf@posteo.net> <87bl4mrq4k.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38103"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Monnier , emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 21 16:19:44 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mSgcY-0009jr-O6 for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Sep 2021 16:19:44 +0200 Original-Received: from localhost ([::1]:53442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSgcX-0006IG-KF for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Sep 2021 10:19:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSgbU-0005Qb-RA for emacs-devel@gnu.org; Tue, 21 Sep 2021 10:18:36 -0400 Original-Received: from mail-oln040092064109.outbound.protection.outlook.com ([40.92.64.109]:13473 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSgbN-0003yS-SE for emacs-devel@gnu.org; Tue, 21 Sep 2021 10:18:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRckVcZ61HLRiEOqYNuG8nXugPZA5U+SHRZs3Dl2K0rl76ENVclkN1G0oeLtUcOOVPW8tq/y40b9HK0+5ZNqk8azT6SEcjYB3gvPAW0IcIdJzUw9OHynEzOYqJEHP2AEfmcs6NgUJDsDJaQ0BBPq4pBHGXWksXfTY16Q5b0OjvEWQMZ6XfFD3htJjyXrVA2qiNWl8RZDk+MdFq72erppvn4NSkgMZLjHcAF7b8R/iBWzq2akrNYQ5jGujfEzVnFMLgnluBkqvS9A0ldl4vQdBe38gBXxpHU6HeRsNzhbtZ7nzFTuNrrPZW/LSWpFnUHLA7UDijeqkuFBKpLQ0NQFPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=U3rzeXlMzUqsKoh5S8Hjtdb8PDcmS1UuHKPiQEHPEu4=; b=NweNH/KpDxMk0JklNqRNigrnvNLjZGlreUVMQAqhyDf2GD4KO1ncS3sLerKBEjz5CUSJfUvuVQOapExF1TIGCPOV1QoBYPZuqtugpVZIdImwO2kbCkn1xyjAKN77CvYg8u0RDUDX971HY8kSjr+jjQ7OKSDzIFkR8fz2gm55DoC48HUAmmxBUbmKIM/l6fKwYOQj2jXhgTDhHInrWCO3vmpJFbU/JZxQVpDq2qmUGRzvk1QtW4tiedg1QRz1lb6b2RrZSaulPeyRZcLTortPsyT/pUfJq60KB1DX+UUguQHUKSBkjB1sloUY0PxYQoGGvmWwe+Npc7KEeJMW2YBuSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U3rzeXlMzUqsKoh5S8Hjtdb8PDcmS1UuHKPiQEHPEu4=; b=t819NA26lojz2FUT9vc87Z7UjNStyQve2Ps9vUE4o8hRNRs8g3bD9V7CnPTGueQSxjNVzU4a2GRD4OuVfExUoxdM8VjGUbONocbXYgF/exxRYagtLb9dkzbZ7/3FMBbeg6XexMa19J0TV/SwvNlWx9uPh1UzJDidjWl5irjVhP3reVwa6fBGsTX0qTCFa1RTokLqZUsVxikkcWhZOKgCjO0gS/kqaRnNkIMYsm//LcR8D8Ug+wdNwCA+ybMfqfR48Uh1DUHxzG3bn4gpsJe25gsroFYID13NUmfci2IuoRcZHSDXhrz3eBz6TmSx0qDEPIK8I7z4C/n6DWvX+qvATw== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB4068.eurprd09.prod.outlook.com (2603:10a6:208:191::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.17; Tue, 21 Sep 2021 14:18:27 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4544.013; Tue, 21 Sep 2021 14:18:27 +0000 In-Reply-To: <87bl4mrq4k.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 21 Sep 2021 13:54:03 +0000") X-TMN: [iCa4e8Hw9ly90t9k0KzOTJzXgbvpZaFv] X-ClientProxiedBy: OL1P279CA0003.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:12::8) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87k0jaqafi.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by OL1P279CA0003.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:12::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Tue, 21 Sep 2021 14:18:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc58eb39-6ebd-4266-72bc-08d97d0aadbd X-MS-TrafficTypeDiagnostic: AM0PR09MB4068: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i3FeF7rkfWowWSS89kS1BAPcT4V+qJRSnOjSjYiSM5VOP3fP8BIzoT3RcGNeUgaz8Oo+EnYX9vKOZRQ0A/42fihCwlEvasMTqekW2epWCC3W47k0qdaqzDukBttCUzjYL0JGragcQJb9LT3cTgwd42RN4hMEnfI2KTxNTnYo334Ry53wFYJmPRDm9KhlRyNECCa+Zv6M8b/GtqwDCdr4hMqSvL68/ZV/POK3A5UwP1oPchHhg9DddtxGpKSpJAw85TOledz6D/PpP5cHM+rqorDmz863K0xIm4udocoJXsqsGlyaAZ5GbHgYwS2yxR5GOoGtqxPEs6xIfr3Cp/VPSj+ndCLc5TGGzFoLCP5KKmfybLCE2Wcj6WGeXlueIv0TtBDG8SR7YwNKrq6H7zfPbValpcvs+bWFGidV8eXU4CkgD40wxuid9Ooh/mo7I6a3 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OoLWAfXHVO4TNYTgVOJjNdsBir699asE2MU9eDXgXvguR89lUkl2K584lh45sioXr0p1ium+HlFubUElIDZGOFP4IlGQKkuLs7j4EX4DOZxG49/r5LTHWGkEP8iiyD5WuKs80BYuqa6WF/jDvwAUNg== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: fc58eb39-6ebd-4266-72bc-08d97d0aadbd X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 14:18:27.1179 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB4068 Received-SPF: pass client-ip=40.92.64.109; envelope-from=arthur.miller@live.com; helo=EUR01-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275243 Archived-At: Philip Kaludercic writes: > Arthur Miller writes: > >> Philip Kaludercic writes: >> >>> Stefan Monnier 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). Ah, ok, sorry I wasn't running any code; just so the advised directory-files and that directory-empty-p used one with the counter. My bad. >> 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.