From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= <joaotavora@gmail.com> Newsgroups: gmane.emacs.bugs Subject: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind` Date: Fri, 12 Jan 2024 10:46:43 +0000 Message-ID: <CALDnm52=voD5PrnsU58wQR1omwymYdUALEAueqsQTZujU6i0rQ@mail.gmail.com> References: <277dd49a-e96d-4faf-a22e-aca952354a37@protonmail.com> <jwvplzllrrm.fsf-monnier+emacs@gnu.org> <30f1bf76-1cf1-493e-be4f-38e405d0ecf6@protonmail.com> <CADwFkm=7bc5__WNzZftWt01cnQt4NpnFez+LmqJo9qnieN2nCQ@mail.gmail.com> <CALDnm51VjpjCp4xLPfQ-qR1iwxdDc5XX0i3=8M1vW6vUDizMTw@mail.gmail.com> <jwvwmsfntmc.fsf-monnier+emacs@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000000446ff060ebd62e3" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13636"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Okamsn <okamsn@protonmail.com>, 67611@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com> To: Stefan Monnier <monnier@iro.umontreal.ca> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 12 11:48:15 2024 Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org> Envelope-to: geb-bug-gnu-emacs@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 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>) id 1rOF5D-0003Jf-LG for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Jan 2024 11:48:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <bug-gnu-emacs-bounces@gnu.org>) id 1rOF53-0002nK-MN; Fri, 12 Jan 2024 05:48:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rOF52-0002nC-Ua for bug-gnu-emacs@gnu.org; Fri, 12 Jan 2024 05:48:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rOF52-0000mq-H1 for bug-gnu-emacs@gnu.org; Fri, 12 Jan 2024 05:48:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rOF50-0003i3-Cl for bug-gnu-emacs@gnu.org; Fri, 12 Jan 2024 05:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= <joaotavora@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jan 2024 10:48:02 +0000 Resent-Message-ID: <handler.67611.B67611.170505642313893@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67611 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix notabug patch Original-Received: via spool by 67611-submit@debbugs.gnu.org id=B67611.170505642313893 (code B ref 67611); Fri, 12 Jan 2024 10:48:02 +0000 Original-Received: (at 67611) by debbugs.gnu.org; 12 Jan 2024 10:47:03 +0000 Original-Received: from localhost ([127.0.0.1]:35019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1rOF42-0003c0-Ak for submit@debbugs.gnu.org; Fri, 12 Jan 2024 05:47:02 -0500 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:57741) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <joaotavora@gmail.com>) id 1rOF40-0003bF-KV for 67611@debbugs.gnu.org; Fri, 12 Jan 2024 05:47:01 -0500 Original-Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2cd1ca52f31so72880821fa.3 for <67611@debbugs.gnu.org>; Fri, 12 Jan 2024 02:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705056416; x=1705661216; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=b1Q4CSdpZMvC0iQ91RGAlHqAakJy4dp/wmBoyUHlFmM=; b=PSJZwEn0cKyq39Hx55GfBVlEFc+2+Y4iPm0fkSDt3io/IvR14MFMXFKIW68IhXzh9l kfbSq8aRdCpWankL8tHqYeLSa3Pp5vLWytZAZEFroqEp7G23E50arLcmq9Sb9KzWMZbR G91ZRA+W0xVK3kuoLPFqjaYDtFbe5gs2oGMam7UqEPwS/U1K3E0Ro8dAx/7ZBCe6iVfl 1jPp/N8ywJhrfwz1zmlAD0kvY2O+pO5TKk92boFEb7FjkuT9KfwdPRiXImsK8MhtpS5h RtCw/ReX/iP0tdvojXmelIF5zooaFPKBc46iPO0s1iSgn5oOCQU1Vk53QGXcj+haA8vj o2eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705056416; x=1705661216; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b1Q4CSdpZMvC0iQ91RGAlHqAakJy4dp/wmBoyUHlFmM=; b=rKDyyPEoRIWChq2Ll/grg+YS545VW64Y5o9QKVrNjLD74z50n6bxn9nQ19gfWWXOAS 4flvJy4+XjoK5D09RMhQnsLIzwWU2DDXq5pdKQ8bQBlplHRArJ69XjsSqNBA46Lb2DVN Xwr8v740vvcTKzQuwuGysVgIahlG7P34B4MAKF2ZxkjRSXWoe9yG8bmMFnldYTltFEwR D7bZ2x+UOh3jB59BftuSZBu+WAJe0MWjnHxhgE8L6OBt53k360rBQouc1q2ujEtF1Phw 3MfyHGXirfMZ3N2PIlZrAwHjQnwDFbtZX5FxwsTxq4fMWpqkDBv16qhBfppa5Tbtx/rM jHAw== X-Gm-Message-State: AOJu0YwPhD4MsiQzwI3MmRw2mdIHjAUJ3p8swcAPfdpPMzmYMvvBorY8 AyjsD/u+mxOmbuGdeZkxqvITC4oFlMMkcny41M4= X-Google-Smtp-Source: AGHT+IFvED/vFzKiTgEDupCXvdBOPFHRBRaqfGiPYLMcE0YlWa/aUMdCPPAQIU02i1wKP6pso/HdUCMQD6hEeBBwZ8w= X-Received: by 2002:a2e:c51:0:b0:2cd:9959:53a0 with SMTP id o17-20020a2e0c51000000b002cd995953a0mr417315ljd.1.1705056416317; Fri, 12 Jan 2024 02:46:56 -0800 (PST) In-Reply-To: <jwvwmsfntmc.fsf-monnier+emacs@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>, <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs> List-Post: <mailto:bug-gnu-emacs@gnu.org> List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>, <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe> Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278010 Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/278010> --0000000000000446ff060ebd62e3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 12, 2024 at 3:05=E2=80=AFAM Stefan Monnier <monnier@iro.umontre= al.ca> wrote: > I don't think there's a clear enough need for it right now in Emacs core > to motivate its integration in Emacs proper. Also, because several > people have expressed an opinion that leans towards recommending that > Emacs's own code should probably better avoid using this functionality. Those people are trying to come up with alternative pattern-matching libraries which we start to see are not simpler or as powerful as pcase. But sure, other pattern-matching libraries exist out there. See CL's optima/trivia [1/2] for some very good ones. Emacs just happens to have pcase readily available. > I'd be quite happy to include such a think in GNU ELPA, OTOH. Could be, but why really? Why are CL things which rest on such high-quality well-known designs, older than many things Emacs, relegated to a place where they're less discoverable? Here, I think at least the new fresh implementation of lambda-list parsing (which is the meat-and-bones of this patch) is worth taking a look at. It's the function 'cl--pcase-cl-lambda-var-groups'. I would definitely consider grooming this function, renaming it, and keeping it in core, exposing to general Elisp usage in cl-macs.el (or cl-lambdalist.el, cl-ll.el), even if a new pcase pattern that uses it goes to ELPA (but why, really?) That util could help us write other lambda-list destructuring alternatives that understand &optional, &rest. Because with or without it, we already use a lot of the &optional, &rest explicitly in Emacs. And we also use &key and &allow-other-keys in many other places, though sometimes in ad-hoc lets-not-call-this-bull-by-its-name fashion. IOW there is no general purpose-util like Alexandria's 'parse-ordinary-lambda-list', and this could be it. It could not only be used to simplify and add coherence to many of these existing compile-time structures, for example helping simplify things and address FIXMEs in cl-lib.el. Jo=C3=A3o [1] https://github.com/m2ym/optima [2] https://github.com/guicho271828/trivia --0000000000000446ff060ebd62e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">On Fri, Jan 12, 2024 at 3:05=E2=80=AFAM Stefan Monnier &l= t;<a href=3D"mailto:monnier@iro.umontreal.ca" target=3D"_blank" rel=3D"nore= ferrer">monnier@iro.umontreal.ca</a>> wrote:<br> <br> > I don't think there's a clear enough need for it right now in = Emacs core<br> > to motivate its integration in Emacs proper.=C2=A0 Also, because sever= al<br> > people have expressed an opinion that leans towards recommending that<= br> > Emacs's own code should probably better avoid using this functiona= lity.<br> <br> Those people are trying to come up with alternative pattern-matching<br> libraries which we start to see are not simpler or as powerful<br> as pcase.<br> <br> But sure, other pattern-matching libraries exist out there.=C2=A0 See<br> CL's optima/trivia [1/2] for some very good ones.=C2=A0 Emacs just happ= ens <br> to have pcase readily available.<br> <br> > I'd be quite happy to include such a think in GNU ELPA, OTOH.<br> <br> Could be, but why really?=C2=A0 Why are CL things which rest on such<br> high-quality well-known designs, older than many things Emacs,<br> relegated to a place where they're less discoverable?<br> <br> Here, I think at least the new fresh implementation of<br> lambda-list parsing (which is the meat-and-bones of this patch)<br> is worth taking a look at.<br> <br> It's the function 'cl--pcase-cl-lambda-var-groups'.<br> <br> I would definitely consider grooming this function, renaming<br> it, and keeping it in core, exposing to general Elisp usage<br> in cl-macs.el (or cl-lambdalist.el, cl-ll.el), even if a new<br> pcase pattern that uses it goes to ELPA (but why, really?)<br> <br> That util could help us write other lambda-list destructuring<br> alternatives that understand &optional, &rest.=C2=A0 Because with o= r<br> without it, we already use a lot of the &optional, &rest explicitly= <br> in Emacs.=C2=A0 And we also use &key and &allow-other-keys in many = other<br> places, though sometimes in ad-hoc lets-not-call-this-bull-by-its-name<br> fashion.<br> <br> IOW there is no general purpose-util like Alexandria's<br> 'parse-ordinary-lambda-list', and this could be it.=C2=A0 It could<= br> not only be used to simplify and add coherence to many of these<br> existing compile-time structures, for example helping simplify<br> things and address FIXMEs in cl-lib.el.<br> <br> Jo=C3=A3o<br> <br> [1] <a href=3D"https://github.com/m2ym/optima" rel=3D"noreferrer noreferrer= " target=3D"_blank">https://github.com/m2ym/optima</a><br> [2] <a href=3D"https://github.com/guicho271828/trivia" rel=3D"noreferrer no= referrer" target=3D"_blank">https://github.com/guicho271828/trivia</a><br><= /div> --0000000000000446ff060ebd62e3--