From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Okam via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#47261: Destructuring with Pcase without assigning values Date: Sat, 17 Apr 2021 01:24:11 +0000 Message-ID: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> References: Reply-To: Okam 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="374"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47261@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 17 03:36:21 2021 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 1lXZsi-000AX1-2k for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Apr 2021 03:36:20 +0200 Original-Received: from localhost ([::1]:48898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXZsh-0004rg-4m for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Apr 2021 21:36:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXZhm-0003sH-Eg for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2021 21:25:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lXZhm-0007m3-6d for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2021 21:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lXZhm-0004f6-1l for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2021 21:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Okam Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Apr 2021 01:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47261 X-GNU-PR-Package: emacs Original-Received: via spool by 47261-submit@debbugs.gnu.org id=B47261.161862267117838 (code B ref 47261); Sat, 17 Apr 2021 01:25:02 +0000 Original-Received: (at 47261) by debbugs.gnu.org; 17 Apr 2021 01:24:31 +0000 Original-Received: from localhost ([127.0.0.1]:41992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXZhD-0004dY-53 for submit@debbugs.gnu.org; Fri, 16 Apr 2021 21:24:31 -0400 Original-Received: from mail2.protonmail.ch ([185.70.40.22]:15340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXZh8-0004dI-Hk for 47261@debbugs.gnu.org; Fri, 16 Apr 2021 21:24:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1618622655; bh=yyEAiozRx3AzlgRwqKDSaYa6XDlOp9OXlnpbONa5DxE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=uXHAsqbsNk0xjNf4/+4ztWUQA3taGcyrvwBmZEU4Pebz9dC215V148/CsPPWEurgA rzsBcDCGH1MGHAMBRBcpdOgFxnT712ZB/9Gt+Wrp7F9sIL0iVDu+ar4hQ8QM3Agp5y RyHAJ4WNNwTpAZ3UtD1tns243whr6lAkfw+ZPkYc= 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" X-ACL-Warn: , Okam Xref: news.gmane.io gmane.emacs.bugs:204166 Archived-At: On 3/19/21 5:45 PM, Stefan Monnier wrote: > I massaged the code so that it now exports the following function: > > (defun pcase-compile-patterns (exp cases) > "Compile the set of patterns in CASES. > EXP is the expression that will be matched against the patterns. > CASES is a list of elements (PAT . CODEGEN) > where CODEGEN is a function that returns the code to use when > PAT matches. That code has to be in the form of a cons cell. > > CODEGEN will be called with at least 2 arguments, VARVALS and COUNT. > VARVALS is a list of elements of the form (VAR VAL . RESERVED) where= VAR > is a variable bound by the pattern and VAL is a duplicable expressio= n > that returns the value this variable should be bound to. > If the pattern PAT uses `or', CODEGEN may be called multiple times, > in which case it may want to generate the code differently to avoid > a potential code explosion. For this reason the COUNT argument indi= cates > how many time this CODEGEN is called." > > The `pcase` macro itself uses this function, so it should hopefully be > "good enough", but let me know if it's causing you trouble. > > > Stefan > This seems to work well for my use case. Thank you for making this change. Are the variables always given in the order that they appear in the pattern? If not, is finding elements of the form "(\, SYMBOL)" enough to identify variables in a Pcase pattern?