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?= Newsgroups: gmane.emacs.bugs Subject: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind` Date: Thu, 11 Jan 2024 22:46:01 +0000 Message-ID: References: <277dd49a-e96d-4faf-a22e-aca952354a37@protonmail.com> <30f1bf76-1cf1-493e-be4f-38e405d0ecf6@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39225"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Okamsn , 67611@debbugs.gnu.org, Stefan Monnier To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 11 23:47:21 2024 Return-path: 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 ) id 1rO3pZ-0009uO-8n for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Jan 2024 23:47:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rO3pK-0002nr-KY; Thu, 11 Jan 2024 17:47:06 -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 ) id 1rO3pJ-0002nP-7B for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 17:47:05 -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 ) id 1rO3pI-0008Qh-Ue for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 17:47:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rO3pG-00059P-GR for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 17:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jan 2024 22:47:02 +0000 Resent-Message-ID: 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.170501318018376 (code B ref 67611); Thu, 11 Jan 2024 22:47:02 +0000 Original-Received: (at 67611) by debbugs.gnu.org; 11 Jan 2024 22:46:20 +0000 Original-Received: from localhost ([127.0.0.1]:34255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rO3oZ-0004lJ-54 for submit@debbugs.gnu.org; Thu, 11 Jan 2024 17:46:19 -0500 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:53551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rO3oW-0004br-Qj for 67611@debbugs.gnu.org; Thu, 11 Jan 2024 17:46:17 -0500 Original-Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2cd64022164so54496771fa.3 for <67611@debbugs.gnu.org>; Thu, 11 Jan 2024 14:46:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705013173; x=1705617973; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kys6Pu89u53MwLrmp4OUxman5yBnSVGT1Pdhf7vzco0=; b=b9zCvdIZjjvtR9pJ85tNY2+r4wGUg/zT8Pwe1betugLODK8uKKa/V3Ja/sWGYS3Yce 8XVNjGfQ+qpdTyT0FrG4Z6nccQnnqBgwrjlmDq1JwNtonzlMCAlcLrsGs21lSBqx3pMy VFjWDMAEbRXt9OfDDkqWEElFjb+7tjYG932xgJKWNbMQhNx06gHRYkGBOm7X04UQyksM GhuMtpMm75B/FAYshyQpFVl+wwLJoNAJWIA6AcZRTrANaocGsRu4CXn4x+zg9O0Giwhd X4yWGAcpGz0vqtZCOrQn1Dhe9hP2jZIWNGXmjBJturnFG5htC7CtC7ppUaj651y4vNH/ 1QLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705013173; x=1705617973; h=content-transfer-encoding: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=kys6Pu89u53MwLrmp4OUxman5yBnSVGT1Pdhf7vzco0=; b=K5sViKjTqKVeuUXbLm7sKqeZeryrCge5VsglFz6ymPaSykjwuVgnNUWrpl7asph+zJ PyaDmTWlStciL4ZlvSM5SPeZLVAtnFJAvYvuRqcD7f5G8NTmUSBqr+wDMF/1DMKAVZjn z8+S8aX1v/3Yc7F35CqTlaSY+RJpGskeRfP3kUs5NcM/a1CR29SYvjM4rSZZdul2dbHb 8kqSYWrG1Rcf7DmAUDOO4GkqHtuvOTFvcZdUn0JQu9KEPAldFwQVx1eoxOCZeBTU59fR W885Oj46fTPedgsKXNjQqkQO54P+0IFDe/V6oQJdn9ISwqGm7WdI6LC2EtRydDoLE62C wM0Q== X-Gm-Message-State: AOJu0YwDXvFae3k6EdsG+aaJT+DQKinTUDw2J29OSnR9upZ3sk/vt5fk QX3tpqEPfinBZneepgeHEJwGTthYV3l0hOUJQx0= X-Google-Smtp-Source: AGHT+IF4Tiwr2mXOcxrj2ktKVC0TZEVJkiT7FQERI1B+rQmfrmpHLargqRa146//FqLNg7lOhnUBuxpEk/iBbwSrWsU= X-Received: by 2002:a2e:9083:0:b0:2cc:695b:a12b with SMTP id l3-20020a2e9083000000b002cc695ba12bmr213032ljg.85.1705013172901; Thu, 11 Jan 2024 14:46:12 -0800 (PST) In-Reply-To: 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" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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:277969 Archived-At: On Thu, Jan 11, 2024 at 10:13=E2=80=AFPM Stefan Kangas wrote: > > Jo=C3=A3o T=C3=A1vora writes: > > > On Thu, Jan 11, 2024 at 9:12=E2=80=AFPM Stefan Kangas wrote: > > > >> Thanks for the patch. I can only echo the sentiment already given her= e, > >> that making `pcase' more complex won't do much for its popularity. > > > > This sentiment is not unanimous. If pcase is naturally extensible, > > using that ability is not making it more complex. That'd be akin > > to saying "defun" is made more complex because too many functions > > are popping up. > > > > Just wanted register this position. Though I don't know for sure if > > the patch is simply adding a new extension to pcase or changing > > its core structure. > > > > I wish Okamsn would show one or two simple examples usage > > of something you can't do with pcase today, but you would be > > able to with the patch. In the meantime, I've had a look at the patch file to learn about this pcase extension. 1. It is a pure extension. The extension code happens in cl-macs.el 2. It is an alternative to cl-destructuring-bind, also defined in that file, with more typing involved. 3. It _seems_ it has the advantage that it relies on very little of cl-macs.el, like maybe just cl-copy-list. Ie it could easily be changed to live in another file. It could even be a (better?) base to write cl-destructuring-bind and other cl-macs things on top of. And to write other utils like Alexandria's cl-parse-ordinary-lambda-list or destructuring-case [1]. A good lambda-list destructuring tool is valuable by itself, even without pcase integration. 4. Pcase integration is a "nice to have". In the provided tests, the new extension is only tested as a destructuring aid, so I cannot tell very well how it fares int the matching aspect of pcase. For example I did this experiment: (pcase (list 42 41 :c 42) ((cl-arglist (42 42 &key c)) (list c)) ((cl-arglist (42 b &rest more)) (list b more))) This matches the second case, which is good and returns (41 (:c 42)) But how do I construct a case that matches only if the provided value to c is 42, if this is at all possible? > feel free to reopen the bug report if you think it makes sense. I think it makes sense, but I don't know how to do that. Just write reopen 67611/thanks to this tracker? Jo=C3=A3o [1]: https://gitlab.common-lisp.net/alexandria/alexandria