From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72328: [PATCH] Nested backquote in pcase Date: Mon, 29 Jul 2024 19:45:29 +0300 Message-ID: <867cd4ywnq.fsf@gnu.org> References: <87jzh62vtr.fsf@gmail.com> <877cd5k1ra.fsf@web.de> <871q3d347e.fsf@gmail.com> <877cd4rxqo.fsf@web.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11116"; mail-complaints-to="usenet@ciao.gmane.io" Cc: thuna.cing@gmail.com, 72328@debbugs.gnu.org To: Michael Heerdegen , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 29 18:46:19 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 1sYTVq-0002fx-VS for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Jul 2024 18:46:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYTVQ-0000xe-K6; Mon, 29 Jul 2024 12:45:53 -0400 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 1sYTVN-0000xR-87 for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 12:45:50 -0400 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 1sYTVM-0008JQ-Tg for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 12:45:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=w4CghIaDUk9LgmWzKOmjFbAaY1+frBxlbhJ27etircI=; b=ZcFlSBmAkCW9ZVIlP8SCpUat3XQYE3K1X2GseHGXHBKjeXrJs3GQWXhigfshNQ9ixOZprfztnDFC+AO8MOEGu7C5s28uaPalxP4o6NSwnsXUOWuSShKl3iRfhmVH3R64gUa1TLsEYvzLC/6WjKkZH6jv12UF1egyUF4euv0dFpjepyvOFYO3g4+inb7RCLH5daDIyDrRRBTRJfciVYkHru3BWsXnvYoC4rzNlN0jmoDOZi9xcJz8OxHMokAABpYLoSjSdFxD5JDysbmY5egJj2zqDrzpuJBxx8oNohW5M+4nPnKh1o2k9d9WczsIYFFsUe74nc9Lj1M2145TV1kX3w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sYTVZ-0000gk-Ku for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 12:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Jul 2024 16:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72328 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72328-submit@debbugs.gnu.org id=B72328.17222715542633 (code B ref 72328); Mon, 29 Jul 2024 16:46:01 +0000 Original-Received: (at 72328) by debbugs.gnu.org; 29 Jul 2024 16:45:54 +0000 Original-Received: from localhost ([127.0.0.1]:46225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sYTVS-0000gO-Do for submit@debbugs.gnu.org; Mon, 29 Jul 2024 12:45:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sYTVO-0000gA-AA for 72328@debbugs.gnu.org; Mon, 29 Jul 2024 12:45:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYTV5-0008FU-62; Mon, 29 Jul 2024 12:45:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=w4CghIaDUk9LgmWzKOmjFbAaY1+frBxlbhJ27etircI=; b=TdJzgYbyfDdP f0lWegfSz3SG5CdpTVFnOtabeyyY83s+UMM1CfSgtYSutXjxpv8//EIiBSvMR3u1ceT/nwKiSYUUJ /uXjzjMcUr6xI2wWmD2cCogxYHPIayObtQlwBbPjgT9JXlj/7EHlJBpf+dtDNQSXNtNH/0y5I4xi1 Gdmhfcjo8VcXeFTUYFzorVB7b75EjQp6ubKnPip4ucCNPjpFS2mBu8VJIr2VGj5S7cGQJNjMceVyA SMBVgvB1vRcCUEBzVP/Y8jCJdphfojTmt6Zj+3UvvDCxuYPKbdKJ6DWFO80JKNlEGd4qJJ0D/3TNr hEQF4t2cXB55YCQO0mD7Ew==; In-Reply-To: <877cd4rxqo.fsf@web.de> (bug-gnu-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" 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:289524 Archived-At: > Cc: 72328@debbugs.gnu.org > Date: Mon, 29 Jul 2024 18:03:59 +0200 > From: Michael Heerdegen via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Thuna writes: > > > > This would be a backward-incompatible change, breaking existing code. > > > > Yes, I forgot to mention this in my original report, but given how > > unintuitive (IMO) the current behavior is, I expect that very few people > > will be using patterns which would be effected by this change. > > We have _dozens_ of such patterns in the Emacs Elisp sources that would > break. Your expectation is wrong. > > > > > And this change would break the symmetry between `backquote' the macro > > > and backquote patterns in `pcase'. This is an important design idea. > > > > I am not quite sure why you think that this breaks symmetry with the > > backquote macro; > > We want that something like this works as expected: > > #+begin_src emacs-lisp > (let ((a 1) (b 2)) > (pcase `(69 foo (97 ,a ((,b)))) > (`(69 foo (97 ,a ((,b)))) > (list a b)))) ==> (1 2) > #+end_src > > I think it's obvious what I mean with symmetry between backquote and > pcase backquote without giving a formal definition. > > > > the purpose of this patch was to establish a symmetry > > in the first place. Would you consider the examples provided as > > unnatural? > > I'm more concerned about what we would loose. > > > > AFAICT right now the only way to match an unevaluated (or quoted) `,foo > > is with `(,'\` (,'\, foo)) which is quite unideal. > > If `foo` is the literal symbol you can simply match using a quote pattern > like in > > (pcase '`,foo > ('`,foo t)) > ==> t > > > > It is not often that you need this but having this not be > > representable in this way is not particularly useful. > > It indeed gets ugly when one wants to match a non-constant > backquote expression using a backquote pcase pattern with partial > unquotes (the "mixed case"). > > But making pcase backquote patterns less expressive just to make this > special case simpler doesn't make sense to me. OTOH I agree that having > a convenient solution for this kind of problem would be nice. Stefan, any comments?