From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thuna Newsgroups: gmane.emacs.bugs Subject: bug#72328: [PATCH] Nested backquote in pcase Date: Mon, 29 Jul 2024 19:43:45 +0200 Message-ID: <87v80o14by.fsf@gmail.com> References: <87jzh62vtr.fsf@gmail.com> <877cd5k1ra.fsf@web.de> <871q3d347e.fsf@gmail.com> <877cd4rxqo.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17493"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72328@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 29 19:46:13 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 1sYURo-0004OZ-CI for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Jul 2024 19:46:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYURT-0007ct-V1; Mon, 29 Jul 2024 13:45:52 -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 1sYURR-0007cd-Vu for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 13: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 1sYURR-00070V-Lw for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 13:45:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=9iKHdHq+6Mc5iUq6tJlDO0d/+2ylXPcylznmI3B71Zc=; b=eWZojF2FmAdtVlD3hdLQo7IqoNUsrzRevwcTOLJxOgx3XSUAKoCpfs1GIh3K0MUhspZE8FVPC8NQbwMpKhI48run+l4ILHIiWvKx6XNYQ8+KRClsfI9KCN516VZIt4R3inV4OiZIuPCjZa9oXzuXM8K05O9Xtwn+Qur2oTsDl/Vk5KyOzs7tS1L8OQst4wKjQFYv8TgOfhcYFiTqyeEbfoTxFF2k677vOxEt5hyxD+98t+JiwrDZBTooCBmDGit+zlnBdR3KQmy0QIaP0h9uzbUPRZhVQMp6Q5bqYgZ84TZQSGdK4nJ4L/4lRGlAo/3e2frxLXcZh9vGPVIlDDAcGQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sYURe-0002Bv-BD for bug-gnu-emacs@gnu.org; Mon, 29 Jul 2024 13:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thuna Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Jul 2024 17:46:02 +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.17222751108364 (code B ref 72328); Mon, 29 Jul 2024 17:46:02 +0000 Original-Received: (at 72328) by debbugs.gnu.org; 29 Jul 2024 17:45:10 +0000 Original-Received: from localhost ([127.0.0.1]:46283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sYUQo-0002Ap-9Q for submit@debbugs.gnu.org; Mon, 29 Jul 2024 13:45:10 -0400 Original-Received: from mail-lf1-f49.google.com ([209.85.167.49]:45339) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sYUQm-0002AV-3k for 72328@debbugs.gnu.org; Mon, 29 Jul 2024 13:45:08 -0400 Original-Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-52efd8807aaso5791308e87.3 for <72328@debbugs.gnu.org>; Mon, 29 Jul 2024 10:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275028; x=1722879828; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9iKHdHq+6Mc5iUq6tJlDO0d/+2ylXPcylznmI3B71Zc=; b=Ra2zTA7MVbLyODfS7CsDlRXyHl1SFobhjGQQkDB11Wzz+0gfFkrlddhM4DnxyCYLCK itYgzltFnkcFO4Ijp7zBlKbIPKxqx3SkrUCXDkkPL9DE0RS3TUVv9stFbbd2IdYf5t6o AF/hwYbH60Ek50IpUN+zKqXntgEXlHt2hhxLol/3FDyBdPheSdMyHkp5C6Zavb+/5Zil Krdo1CNt7q666xfkZbNVhkTfsFiIacERMV2KWQPwNlJ5JgXbjJKzGVc+VZxRtedsh7Bu KpnaFbuZO6YlZs24BUDsZLGJbw2MpNUerJ2PxowU8fei00uWccglLGrY77gPEC4QFCNt yAUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275028; x=1722879828; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9iKHdHq+6Mc5iUq6tJlDO0d/+2ylXPcylznmI3B71Zc=; b=K3Bxn/kqYo7Y3Iisru5XjfHw4x8eextwD70W9pQBQLLcZdox5lJvqvma/mNgiH8e3p yYuMRZAkoLhp0N4VgyEqRUfkQnCUhwLLu7IvDk2esNzNXP4SNN25yFLKSZMQKTVzJRdq WJ+eq0z0wHA1XV8UCsyrFvBRu/hBfq0ByYoNK6RPgLCSBVQDSBg2MVFwtD8eeKab4q6O x1hxE2xDkGkMMMOrHxkCu6s0vsa3gt8QjaCleS0bO/JEIOpnOz6ZXMhbI4VgLSEsxhjj ec61YtlxQK9/tJKQZvfjr688BLofduKckxuzU9n4I/EPYPDV8j6k97d15WeHT4D2dYVC gdXA== X-Gm-Message-State: AOJu0YzpIiUTbFMyAZndFxiBs5GcSZOtTscybwp0J6JFsDyvP65D5tXG h4UM7d7pP5M/JhB1s18bqk8krp11bwjv+Ul7QpBu0TOU1Yjsy0HFKY4p1fMbd98= X-Google-Smtp-Source: AGHT+IHbjPgCbQqf+XXJiX7vx7MQObIEqCeugkMIFLdCsHi0cOE6iRpLMsQ9zcUoSL93GiqeriWfoQ== X-Received: by 2002:a05:6512:ac2:b0:52b:c1cc:51f1 with SMTP id 2adb3069b0e04-5309b281170mr6403376e87.23.1722275028030; Mon, 29 Jul 2024 10:43:48 -0700 (PDT) Original-Received: from thuna-lis3 ([85.106.105.81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acadb8072sm533235766b.196.2024.07.29.10.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:43:47 -0700 (PDT) In-Reply-To: <877cd4rxqo.fsf@web.de> 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:289525 Archived-At: >> > 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 feel like there is a possible misunderstanding. I am not preventing a backquote pattern from going deeper into a list. Your example would remain perfectly consistent under the new behavior. What *wouldn't*, however, is something like (let ((a 1) (b 2)) (pcase `(69 foo `(,bar ,,a ((,,b)))) (`(69 foo `(,bar ,,a ((,,b)))) (list a b)))) Which currently errors on two counts: 1. ,,a in the pattern first expands the initial , as though it escape the backquote pattern (not the one before (,bar...) but the one before (69...)) and tries to match the object - which is (\, 1) - against the pattern ,a which is of course nonsense so the macroexpansion fails. 2. ,bar in the pattern tries to match the corresponding object - which is (\, bar) - against the pattern `bar' which binds the object - once again (\, bar) - to `bar'. Do you disagree that the result of this form should also be (1 2)? > I think it's obvious what I mean with symmetry between backquote and > pcase backquote without giving a formal definition. Unless our definitions of symmetry are different, the example above is a clear situation where the current behavior does not have symmetry with the backquote macro. > 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. The drawback of this new behavior would be that you could not match, say, the unevaluated object ``10 against `` where indicates an integer, as ``,,(pred integer) would match against a `(,'\` (,'\, ,(pred integer))). We can still match it, but only with the same ugly syntax as before: `(,'\` ,(pred integer)). While this is not ideal, I still consider the new behavior an improvement.