From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind` Date: Fri, 12 Jan 2024 00:55:47 +0000 Message-ID: <5a26a4ee-ba12-448b-9606-a09f9396d9ea@protonmail.com> References: <277dd49a-e96d-4faf-a22e-aca952354a37@protonmail.com> <30f1bf76-1cf1-493e-be4f-38e405d0ecf6@protonmail.com> Reply-To: Okamsn 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="5794"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67611@debbugs.gnu.org, Stefan Monnier To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 12 01:57:17 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 1rO5rI-0001Is-Tz for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Jan 2024 01:57:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rO5r9-0005ZQ-9h; Thu, 11 Jan 2024 19:57:07 -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 1rO5r7-0005Yv-3R for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 19:57: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 1rO5r6-0001SN-Pf for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 19:57:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rO5r4-0004lP-Dl for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 19:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Okamsn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jan 2024 00:57: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.170502096518244 (code B ref 67611); Fri, 12 Jan 2024 00:57:02 +0000 Original-Received: (at 67611) by debbugs.gnu.org; 12 Jan 2024 00:56:05 +0000 Original-Received: from localhost ([127.0.0.1]:34403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rO5q9-0004kC-7Y for submit@debbugs.gnu.org; Thu, 11 Jan 2024 19:56:05 -0500 Original-Received: from mail-40133.protonmail.ch ([185.70.40.133]:36765) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rO5q3-0004jY-6N for 67611@debbugs.gnu.org; Thu, 11 Jan 2024 19:56:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1705020954; x=1705280154; bh=I0rHUjNaHz8X3kgvFvmvQcpsWssCScHfVZXJxKI0tJk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=o5iTb9IHKc1CVUMbxOIKCmrW8DX72XazxVSvX2QKu7j/07+YLf6irmln5/Nvymm4p AvsRQqFy51EKdgBZXOIhk8um2ppof2xgcy9IyGqvWzwK6sCLrKZRZelf6Q/Up4DWKR pirNkjALOvqh0RU8IS4WhFQvauiN8P8BmU7JpMl8LOe2aGzGAKT3uRdcauTo2NTItt Ap/yaKIi5sGgIEODou82G9EbRYIWlvJXRcfNR0Xi5E8jA7IHu+2vbw3ebCzxEFiWxt W8q5guJBBhBL7MbNkC5GXOCRuJYS0KgwmCZv44QsQK1nVt6dF0Z22196Rirg8ELPC1 uRRThXGnOn4RQ== In-Reply-To: Feedback-ID: 25935600:user:proton 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:277974 Archived-At: Jo=C3=A3o T=C3=A1vora wrote: > 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: >=20 > (pcase (list 42 41 :c 42) > ((cl-arglist (42 42 &key c)) > (list c)) > ((cl-arglist (42 b &rest more)) > (list b more))) > ;; =3D> (42 2) > This matches the second case, which is good and returns (41 (:c 42)) >=20 > But how do I construct a case that matches only if the provided > value to c is 42, if this is at all possible? It is possible. You can give a pattern instead of a symbol for the=20 variable, but you have to use a version of `&key` variables in which the=20 pattern can't be confused for the normal `((KEY VAR) DEFAULT SUPPLIED)`=20 form. Please try the following: ;; =3D> (42 2) (pcase (list :c 42) ((cl-arglist (&key ((:c (and 43 c))))) (list c 1)) ((cl-arglist (&key ((:c (and 42 c))))) (list c 2))) ;; =3D> (42 2) (pcase (list :c 42) ((cl-arglist (&key ((:c (and 43 c))))) (list c 1)) ((cl-arglist (&key ((:c (and (pred (equal 42)) c))))) (list c 2)) ((cl-arglist (&key ((:c (and 44 c))))) (list c 3)))