From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#43100: 28.0.50; pcase not binding variables conditionally Date: Sat, 29 Aug 2020 14:27:51 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000009dd90c05ae04fb9c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1723"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43100@debbugs.gnu.org, Stefan Monnier To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 29 16:29:12 2020 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 1kC1qx-0000KQ-QO for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 16:29:11 +0200 Original-Received: from localhost ([::1]:47518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kC1qw-0001RR-Hl for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 10:29:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kC1qo-0001RH-Bx for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 10:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kC1qo-0007lO-31 for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 10:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kC1qn-00012q-VN for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 10:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Aug 2020 14:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43100 X-GNU-PR-Package: emacs Original-Received: via spool by 43100-submit@debbugs.gnu.org id=B43100.15987113163985 (code B ref 43100); Sat, 29 Aug 2020 14:29:01 +0000 Original-Received: (at 43100) by debbugs.gnu.org; 29 Aug 2020 14:28:36 +0000 Original-Received: from localhost ([127.0.0.1]:48830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kC1qN-00012C-Lc for submit@debbugs.gnu.org; Sat, 29 Aug 2020 10:28:36 -0400 Original-Received: from mail-oi1-f175.google.com ([209.85.167.175]:46197) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kC1qL-00011z-Sw for 43100@debbugs.gnu.org; Sat, 29 Aug 2020 10:28:34 -0400 Original-Received: by mail-oi1-f175.google.com with SMTP id v13so3247707oiv.13 for <43100@debbugs.gnu.org>; Sat, 29 Aug 2020 07:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6u8FltFOkxdmCm/81vkgwSZ7zo0QrqGTmTZfDtrkVzc=; b=EaEzAWt6vXk5C8WNXSnOW8+6zCkgiA8ZVCaEBl0qRzEZshenpdiJnr5m6F6yTLZ6If 6y52TeTXGJfCHZrjU0zy49IUNl7zPnwOjrxR8gF5Ejee04cYm0re+oH1GyLIxm+a1V93 Wm+q/7D6z8Q2D4dES8UmV67VbwjXvrp9wmKOUZIy2K9WDohIi8dF4QdG1JrjDUmXzPZl cR90sygtHMqmW2V7SBjKk2DParhofKcbsxe5AQlkMB4+Au4EAWv/Ej9EBuGWquiuuKVr frQsK16JXJQyx5KNluUH4oWMo2unxkXC9umNTs/edsoZ9LnKUkr76bO4PBgqY+n/3Svv +qeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6u8FltFOkxdmCm/81vkgwSZ7zo0QrqGTmTZfDtrkVzc=; b=Z2i4Cvi197vcj9mznrlXpzMj70FbeBh3Yi6SQVjZbuGytLyrzhw6bVcXO+GJvMUMQj yqvUhggpVByNja9oI34O0VgmVrUk1l0BNZdcPOJxNBBF+jcwW6nMA1ZcfbvG1KZizGcf fqOZYaeczgxN3aF+Hjk5TEwD6jymwwNk2T8+p3oD6xm3JdPWkgGzJdsRs6F+aVNiYtU8 kwZEkDEpfrtagXbZVxIdObhAaVBnPXIhgYaoLd5hA+mJtjf2siIE0KHFGWyMOpIVK0RB 8/UBfbcNPNchOIwj1q7tnhFVzJvpuat+gUlzHl6k/hW51FUWUVcPbi4lNa2BFSL4BQJg uVEg== X-Gm-Message-State: AOAM531uGhQrdbvtUNcd9a0ztTxsmYueHkfl0WykAE+obMR7VVfyi1+d KVVQthMJwJcd1RcLMh3PqaZoRVH7utRtd76Pcxk= X-Google-Smtp-Source: ABdhPJw4wppa/HTFsU8ADOALrsLDgFhdCowER/WGfbJfX31TNpVOr2I3lotdlR5ZrwLsrJezSaZEReVdOjwqHvXHEFM= X-Received: by 2002:aca:dc04:: with SMTP id t4mr2060951oig.30.1598711308071; Sat, 29 Aug 2020 07:28:28 -0700 (PDT) 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" Xref: news.gmane.io gmane.emacs.bugs:186641 Archived-At: --0000000000009dd90c05ae04fb9c Content-Type: text/plain; charset="UTF-8" On Sat, Aug 29, 2020 at 12:01 PM Philipp Stephani wrote: > Am Sa., 29. Aug. 2020 um 11:42 Uhr schrieb Pip Cet : > > I'm having trouble with pcase's behavior. > > > > (pcase "a" > > ((or (pred symbolp) name) > > (let ((foo 'bar)) name))) > > > > throws an error. It shouldn't. > > Isn't this case documented in the manual? The last section of > https://www.gnu.org/software/emacs/manual/html_node/elisp/pcase-Macro.html > states: > "It makes no sense for each sub-pattern [in an `or' sequence] to > let-bind a different set of symbols because the body forms have no way > to distinguish which sub-pattern matched and choose among the > different sets." Thanks for pointing this out. I disagree with what the documentation says there: it does make perfect sense, to me, to conditionally shadow a (lexical) let binding with a pcase-let one, and body forms will have no trouble in practice distinguishing between the outer and the inner let-binding. The code obviously attempts to handle this case, too, it just doesn't get it perfectly right. I agree and accept that pcase is very limited, and it probably always will be, but I think those limitations shouldn't be entirely arbitrary, and hitting them shouldn't cause silently malfunctioning code but error messages. Things like the behavior of (pcase-let ((`(,a ,@b) (list 3 4))) a) just seem puzzling to me. There are good reasons not to implement sublist matching (though I don't think those reasons are sufficient not to have a simple implementation anyway), so an error message would be acceptable, but the current implementation treats \,@ as an ordinary symbol, which doesn't help anyone. Sorry for complaining. Here's a patch. --0000000000009dd90c05ae04fb9c Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Complain-about-in-backquote-pcase-patterns.patch" Content-Disposition: attachment; filename="0001-Complain-about-in-backquote-pcase-patterns.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kefr9tay0 RnJvbSBjNTI3MDhkOTJkZWM0YTZkNzgxMGQ2MzRkZDRmZjIzYTJjYmNhMWVjIE1vbiBTZXAgMTcg MDA6MDA6M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