From unknown Wed Jun 18 23:04:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#47261 <47261@debbugs.gnu.org> To: bug#47261 <47261@debbugs.gnu.org> Subject: Status: Destructuring with Pcase without assigning values Reply-To: bug#47261 <47261@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:04:05 +0000 retitle 47261 Destructuring with Pcase without assigning values reassign 47261 emacs submitter 47261 Okam severity 47261 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 19 09:47:53 2021 Received: (at submit) by debbugs.gnu.org; 19 Mar 2021 13:47:53 +0000 Received: from localhost ([127.0.0.1]:49094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNFTk-0001Yk-Va for submit@debbugs.gnu.org; Fri, 19 Mar 2021 09:47:53 -0400 Received: from lists.gnu.org ([209.51.188.17]:39754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNFTh-0001Yb-Dw for submit@debbugs.gnu.org; Fri, 19 Mar 2021 09:47:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNFTh-0003Ej-0j for bug-gnu-emacs@gnu.org; Fri, 19 Mar 2021 09:47:49 -0400 Received: from mail-40134.protonmail.ch ([185.70.40.134]:31163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNFTb-00079p-J3 for bug-gnu-emacs@gnu.org; Fri, 19 Mar 2021 09:47:48 -0400 Date: Fri, 19 Mar 2021 13:47:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1616161654; bh=GHIwvHhy9lfE5sUHeTWWPAS/uP9JahkgXQMJkRfOyNM=; h=Date:To:From:Reply-To:Subject:From; b=XAIiXpwekaep7o+UQt2huiFeMZDB/xJW9Gm2EQKrZ+OeLRv4pJTtJfqhe4E4DrtWc eFpkd2oPGCDna+4DrGaOV0LfaH54jQpWE5D4YcMdFsJsjVSmmV9IQDvRV8UFyUEYGJ FKN0OmCe0fU2h2EcrK5N+MXzwGn3ws8VsheD6RT0= To: bug-gnu-emacs@gnu.org From: Okam Subject: Destructuring with Pcase without assigning values Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Received-SPF: pass client-ip=185.70.40.134; envelope-from=okamsn@protonmail.com; helo=mail-40134.protonmail.ch X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Okam Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) X-Debbugs-Cc: monnier@iro.umontreal.ca Hello. For a Pcase pattern, it would be convenient to have Pcase destructure the pattern and have a way to see what values Pcase would like to assign to variables within the pattern. This would allow one to know the variables found in the pattern and to manipulate the values that Pcase would like to assign, instead of just letting `pcase` assign them. This was asked about on the Help mailing list: https://lists.gnu.org/archive/html/help-gnu-emacs/2021-03/msg00089.html Thank you. From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 19 17:46:45 2021 Received: (at 47261) by debbugs.gnu.org; 19 Mar 2021 21:46:46 +0000 Received: from localhost ([127.0.0.1]:51144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNMxB-00028R-Mi for submit@debbugs.gnu.org; Fri, 19 Mar 2021 17:46:45 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNMx9-00028C-7E for 47261@debbugs.gnu.org; Fri, 19 Mar 2021 17:46:45 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B345D10023D; Fri, 19 Mar 2021 17:46:37 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 34370100225; Fri, 19 Mar 2021 17:46:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1616190396; bh=FlTUENx/vNRhFzucZIodnPIhwMyH9igvjOQVPJRsR68=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=ir6to1KI1VPfuwHbK0rssLODvKvdimHkbYFIYZ1d/xqlGbMwjmPTklDdp0t7ovm7R r73qaFbg2v0qFZ7a2Cy3yAvRcXl1RgAPSUIVRW/Bj8cmd4Xf2SE+dGZgE3DlBXCByg XiV2G6vMXuLq0r4uiqbnl6cOoYLwg+Qu2G+IhtowQ3/Mnv9xoQcWOmt/zj6u71I+nY 3r3WBlTe4AR/cT2fW1t0apJi/llGFMT4oPeKCfMWiBunRJZyUtSG9obzbjeuiGJx5S iHhfJabhsQEqPw4zhzWbwn6OEMK8DwvV7mrT8fJjZZShNGWMiLWOAjY1g/5pMm72fF vY6/VZD013iIw== Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 06659120263; Fri, 19 Mar 2021 17:46:35 -0400 (EDT) From: Stefan Monnier To: Okam Subject: Re: bug#47261: Destructuring with Pcase without assigning values Message-ID: References: Date: Fri, 19 Mar 2021 17:45:00 -0400 In-Reply-To: (Okam's message of "Fri, 19 Mar 2021 13:47:29 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.099 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 47261 Cc: 47261@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > For a Pcase pattern, it would be convenient to have Pcase destructure > the pattern and have a way to see what values Pcase would like to assign > to variables within the pattern. > > This would allow one to know the variables found in the pattern and to > manipulate the values that Pcase would like to assign, instead of just > letting `pcase` assign them. 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 expression 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 indicates 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 From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 16 21:24:31 2021 Received: (at 47261) by debbugs.gnu.org; 17 Apr 2021 01:24:31 +0000 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 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 Date: Sat, 17 Apr 2021 01:24:11 +0000 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= To: Stefan Monnier From: Okam Subject: Re: bug#47261: Destructuring with Pcase without assigning values Message-ID: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 47261 Cc: 47261@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Okam Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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? From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 16 23:23:21 2021 Received: (at 47261) by debbugs.gnu.org; 17 Apr 2021 03:23:21 +0000 Received: from localhost ([127.0.0.1]:42014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXbYD-0007aH-Nd for submit@debbugs.gnu.org; Fri, 16 Apr 2021 23:23:21 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXbY7-0007Zz-NS for 47261@debbugs.gnu.org; Fri, 16 Apr 2021 23:23:16 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3C3BF80931; Fri, 16 Apr 2021 23:23:06 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4A029801F1; Fri, 16 Apr 2021 23:23:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1618629784; bh=XMNJcte6IC57C3ttyGSutfZzgyft6xj6i9naEH9YCIc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=WqG9QdrSp5k+LaitwTab7UzY4yVVJO+tWgibphxBn4frwzYFSfINwaZv9HLhuph3d x3EKl8PPF9rgWQYitCYEumKSXaYbNUmYGAnGqVrQm2Kc+rD9Kvi9Z7QikDyqFHgcUD UZXK2qVxMCLkZppHGDLJP9wevUecuHALpx2kfUrg3kk5Y+ly3zBdmm8HAt0JD6k5sN rYq3bRuSen/W6ADa8VtukPHIGNLiMT/sRIrkXi/cvkkvB2B/cBNdRgVmtCcSmHwaZ0 nA/ALdNi7Ds7zpR9AiQZXnCEF/FVDIgy4kRweJ2PhkR/+N5j/X1zatyJS6Yj3B2A7m EbwyteuNRbCXw== Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 06960120329; Fri, 16 Apr 2021 23:23:03 -0400 (EDT) From: Stefan Monnier To: Okam Subject: Re: bug#47261: Destructuring with Pcase without assigning values Message-ID: References: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> Date: Fri, 16 Apr 2021 23:22:57 -0400 In-Reply-To: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> (Okam's message of "Sat, 17 Apr 2021 01:24:11 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.056 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 47261 Cc: 47261@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> The `pcase` macro itself uses this function, so it should hopefully be >> "good enough", but let me know if it's causing you trouble. > This seems to work well for my use case. Thank you for making this change. You're welcome. It was actually a good change for the code's readability as well. > Are the variables always given in the order that they appear in the > pattern? I don't know. Why? > If not, is finding elements of the form "(\, SYMBOL)" enough to > identify variables in a Pcase pattern? No. , is not even one of the core pcase patterns, it's only something used within the ` pattern (which is not a core pattern either; it is defined via `pcase-defmacro`). Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 19 18:10:42 2021 Received: (at 47261) by debbugs.gnu.org; 19 Apr 2021 22:10:42 +0000 Received: from localhost ([127.0.0.1]:52295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYc6M-0000w7-2P for submit@debbugs.gnu.org; Mon, 19 Apr 2021 18:10:42 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:29955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYc6J-0000vs-Pd for 47261@debbugs.gnu.org; Mon, 19 Apr 2021 18:10:40 -0400 Date: Mon, 19 Apr 2021 22:10:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1618870233; bh=5JOSoiPyztfACKFQrjhB9/jLsIzgKWvYQPQkhg/Qqcc=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=l1rbzJTyQMapBMO3svN5c021M1ayOk+B1LaULA9VktOmVDp8OhNi+Yen4i9BYLEX+ W45eT60ymPulBk7Y6nVb0a8ow6dJVvSguR7RJtbwy7N+tu42V/HS0BgBR/QoFU6iJ8 C7Miijbz6xvhNiUzb3hNAiL2YPr0fAGq/XHPu5d8= To: 47261@debbugs.gnu.org From: Okam Subject: Fwd: bug#47261: Destructuring with Pcase without assigning values Message-ID: In-Reply-To: <4925d1a5-4669-8290-e534-1662f13ca183@protonmail.com> References: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> <1dacded9-3e40-bc02-56c7-a157d739ffb7@protonmail.com> <4925d1a5-4669-8290-e534-1662f13ca183@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 47261 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Okam Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) For the record, I am forwarding this reply to the bug tracker. I forgot to send the original message to the tracker. -------- Forwarded Message -------- Subject: Re: bug#47261: Destructuring with Pcase without assigning values Date: Sun, 18 Apr 2021 15:15:00 -0400 From: Okam To: Stefan Monnier On 4/17/21 7:37 PM, Stefan Monnier wrote: > >> In the `cl-loop`-like macro that I am writing, things are currently set >> up so that variables being assigned values in accumulation clauses can >> be automatically used as the return value of the macro. >> >> ;; =3D> ((1 3 5) (2 4 6)) >> (loopy (flag pcase) >> (list i '((1 2) (3 4) (5 6))) >> (collect `(,a ,b) i)) >> >> This behavior requires finding the variables in the correct order. >> >> The getting of the variables used ("a" and "b" above) can be done when >> using the new `pcase-compile-pattern`, if the variables are fed to the >> CODEGEN argument in the order that they are written, or I can try to >> find them manually, if possible. > > I still don't understand. AFAICT what the (collect `(,a ,b) i) above is > expected to do is something more or less equivalent to: > > (push (car i) a) > (push (cadr i) b) > > right? > > So a CODEGEN which does > > (lambda (varvals _count &rest _) > (mapcar (lambda (varval) > `(push ,(cadr varval) ,(car varval))) > varvals)) > > should do the trick, regardless of the order in which the vars > are passed. > > I think I'm still missing something in your explanation. > > > Stefan > What I mean to say is that, if possible, I would like to add the variables in the pattern to a list of values to return. This requires identifying the symbols which represent the variables. Using CODEGEN works for setting the values, yes, and is not sensitive to the order in which it receives variables. However, I am currently using the CODEGEN step to add the variables to a list of returned values, since CODEGEN is already being given the symbol for each variable. I am trying to have it so that these variables are listed in the return value in the same order that they are listed in the pattern. For example, this ;; =3D> (4 6) (loopy (flag pcase) (list i '([1 2] [3 4])) (sum `[,sum1 ,sum2] i)) currently expands to (let ((sum2 0) (sum1 0)) (let* ((list-108 '([1 2] [3 4])) (i nil)) (cl-block nil (while (consp list-108) (setq i (car list-108)) (if (vectorp i) (let* ((x109 (length i))) (if (eql x109 2) (let* ((x110 (pcase--flip aref 0 i)) (x111 (pcase--flip aref 1 i))) (progn (setq sum2 (+ x111 sum2)) (setq sum1 (+ x110 sum1))))))) (setq list-108 (cdr list-108))) (list sum1 sum2)))) where `sum1` and `sum2` are in the same order that they appear in the pattern. This works with what I have tested, but I am unsure of whether it is dependable. So, I am asking whether the variables passed to CODEGEN can be relied on to be in a particular order for destructuring patterns, or whether there is a good way to find the variables and their order manually. For example, for `seq-let`-like destructuring, my experience is that the variables are given in the reverse order and that variables can be identified as symbols that are not `&rest`. From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 19 18:31:46 2021 Received: (at 47261) by debbugs.gnu.org; 19 Apr 2021 22:31:46 +0000 Received: from localhost ([127.0.0.1]:52305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYcQg-0001R8-BT for submit@debbugs.gnu.org; Mon, 19 Apr 2021 18:31:45 -0400 Received: from mail-40134.protonmail.ch ([185.70.40.134]:60637) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYc2n-0000qc-Jm for 47261@debbugs.gnu.org; Mon, 19 Apr 2021 18:07:05 -0400 Date: Mon, 19 Apr 2021 22:06:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1618870015; bh=BeiVX9ihKl3r3FJ+mCskx5Tam3YjxPHhHorWTRrismg=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=yPL8gJaKkkyId5SXh83MMlyx6xLP01TfBuvECjHGFXoS1TEDGCzl7NFgPKu8MbKcV AZo5az143sTNbbe7UIb6EhKzqz3Z9H9FL2F2MtGNtyDWUmfAAFPqzQ9H2GmYesqgEo ghspPns9rsg7qT2TjOtbgvVJ5gX4LDyPdttAM1jA= To: 47261@debbugs.gnu.org From: Earl Hyatt Subject: Fwd: bug#47261: Destructuring with Pcase without assigning values Message-ID: <42f78acc-b2f3-9bfd-8891-d316b7a95e1c@protonmail.com> In-Reply-To: <1dacded9-3e40-bc02-56c7-a157d739ffb7@protonmail.com> References: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> <1dacded9-3e40-bc02-56c7-a157d739ffb7@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 47261 X-Mailman-Approved-At: Mon, 19 Apr 2021 18:31:41 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Earl Hyatt Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) For the record, I am forwarding this reply to the bug tracker. I forgot to send the original message to the tracker. -------- Forwarded Message -------- Subject: Re: bug#47261: Destructuring with Pcase without assigning values Date: Sat, 17 Apr 2021 18:50:10 -0400 From: Okam To: Stefan Monnier On 4/16/21 11:22 PM, Stefan Monnier wrote: > >>> The `pcase` macro itself uses this function, so it should hopefully be >>> "good enough", but let me know if it's causing you trouble. >> This seems to work well for my use case. Thank you for making this chang= e. > > You're welcome. It was actually a good change for the code's > readability as well. > >> Are the variables always given in the order that they appear in the >> pattern? > > I don't know. Why? > >> If not, is finding elements of the form "(\, SYMBOL)" enough to >> identify variables in a Pcase pattern? > > No. , is not even one of the core pcase patterns, it's only something > used within the ` pattern (which is not a core pattern either; it is > defined via `pcase-defmacro`). > > > Stefan > In the `cl-loop`-like macro that I am writing, things are currently set up so that variables being assigned values in accumulation clauses can be automatically used as the return value of the macro. ;; =3D> ((1 3 5) (2 4 6)) (loopy (flag pcase) (list i '((1 2) (3 4) (5 6))) (collect `(,a ,b) i)) This behavior requires finding the variables in the correct order. The getting of the variables used ("a" and "b" above) can be done when using the new `pcase-compile-pattern`, if the variables are fed to the CODEGEN argument in the order that they are written, or I can try to find them manually, if possible. If neither are possible, then I will just remove this behavior. Thank you. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 24 14:36:45 2022 Received: (at 47261) by debbugs.gnu.org; 24 Jun 2022 18:36:45 +0000 Received: from localhost ([127.0.0.1]:43522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4oAQ-0000B7-BU for submit@debbugs.gnu.org; Fri, 24 Jun 2022 14:36:45 -0400 Received: from quimby.gnus.org ([95.216.78.240]:35394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4oAO-0000As-Cy for 47261@debbugs.gnu.org; Fri, 24 Jun 2022 14:36:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QTDriXT/0hvz35YPCR9TYQrV9lm7FXJZQMaiF2kIdkA=; b=jqTfId35Z42e2qIBhcNSH9+4yj /MnIHrsY127xQBr0FgfF7BplX9JZt66WXFARl6Gi8EC7BdlN4O2/p7zdwcMjWhanhhW2BBsmeaFab DPqpRXhkHEDsNfMSBDyXl8dz+l4Z3acuH/Y3Skkva8ZIYhSprjeL1JR3ptZ4qM+Us0bk=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4oAD-00042h-AV; Fri, 24 Jun 2022 20:36:20 +0200 From: Lars Ingebrigtsen To: Stefan Monnier Subject: Re: bug#47261: Destructuring with Pcase without assigning values References: X-Now-Playing: Rocketnumbernine's _Meyouweyou_: "Lope" Date: Fri, 24 Jun 2022 20:36:16 +0200 In-Reply-To: (Stefan Monnier's message of "Fri, 19 Mar 2021 17:45:00 -0400") Message-ID: <87r13dnc2n.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: > 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. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 47261 Cc: Okam , 47261@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > 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. Skimming this thread, it seems like this fixed the request, so I'm closing this bug report. (The discussion then went on to discuss some things related to this feature, but if I understood correctly, Earl adjusted his code to fit it.) If I misunderstood, please respond to the debbugs address and we'll reopen. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 24 14:36:45 2022 Received: (at control) by debbugs.gnu.org; 24 Jun 2022 18:36:45 +0000 Received: from localhost ([127.0.0.1]:43525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4oAf-0000Ba-ES for submit@debbugs.gnu.org; Fri, 24 Jun 2022 14:36:45 -0400 Received: from quimby.gnus.org ([95.216.78.240]:35418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4oAY-0000BA-3x for control@debbugs.gnu.org; Fri, 24 Jun 2022 14:36:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1g2LuQYnFIDTj0GuzdqYglaf5TaRMBSbo4ROOQn985A=; b=EnPjfd3wZRM9Bl5mJxVXXS0lhv QqLVikBF3zIKVWbtv0G5XJhBwISszQueXxJm4O4MWG6yMh/vFFx+kkyrNjKrpsdwa7dYb53hcLZPM +xqceYqF7PaCGY6Llv+F/ELP4KbxEdZFKczCFPNFYvqE1e4hL/lA1uZt2kOSKz9Hf84w=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4oAQ-00043D-7H for control@debbugs.gnu.org; Fri, 24 Jun 2022 20:36:32 +0200 Date: Fri, 24 Jun 2022 20:36:29 +0200 Message-Id: <87pmixnc2a.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #47261 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 47261 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 47261 quit From unknown Wed Jun 18 23:04:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 23 Jul 2022 11:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator