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#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected Date: Sat, 20 Jul 2024 13:46:45 +0300 Message-ID: <86r0bocpd6.fsf@gnu.org> References: <87r0d2lfjd.fsf@posteo.de> <87h6dvud8u.fsf@posteo.net> <86tthlidap.fsf@gnu.org> <86frsn55t3.fsf@gnu.org> <865xt0e6wc.fsf@gnu.org> <87ikx0mk4c.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23950"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mekeor@posteo.de, monnier@iro.umontreal.ca, 71503@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 20 12:47:10 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 1sV7cL-00063R-6s for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Jul 2024 12:47:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sV7cF-0006Cx-Oc; Sat, 20 Jul 2024 06:47:03 -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 1sV7cE-0006Cm-FG for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 06:47:02 -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 1sV7cE-0005PV-3D for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 06:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sV7cE-0004GM-7R for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2024 06:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Jul 2024 10:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71503 X-GNU-PR-Package: emacs Original-Received: via spool by 71503-submit@debbugs.gnu.org id=B71503.172147241616374 (code B ref 71503); Sat, 20 Jul 2024 10:47:02 +0000 Original-Received: (at 71503) by debbugs.gnu.org; 20 Jul 2024 10:46:56 +0000 Original-Received: from localhost ([127.0.0.1]:51878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sV7c8-0004G1-77 for submit@debbugs.gnu.org; Sat, 20 Jul 2024 06:46:56 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58138) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sV7c6-0004Fo-Je for 71503@debbugs.gnu.org; Sat, 20 Jul 2024 06:46:55 -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 1sV7c0-0005P0-JW; Sat, 20 Jul 2024 06:46:48 -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=pc8zMUWAkcxM5zOhFo5bavnNPiP1DfwXKldLIJm/j4U=; b=VQm35qZcSNX8 uYtOJB5OrGVOUJyKaTJtOqD6BvJ0ObSn+zTTjxTdvknqnreHXBdTLjYFKmPuzjYZXMTQOM7z0ilNo GZ+W56OWOFBHKDzN99E4Ap304J1QnyOp7NzJvx4FrSHNoRdw5eg2EtTIUSo3ETRrQ1HT8nM0ewU0j tgcL7/HxyT1h/YmvplyLIk+l/xQYmfzOdnYxKR99BpYq7BIkgcX4+6JAIs4b4mltbeWsnGCRq88oB GQU4/OJydSo3h2IMAMx13h4HHpaIFycCBKpfuUICw7JGtIFrsUNzufyTXBH9samDemAzeJC2lws4e gU3cHtD1MsvEqeNb5iBCUA==; In-Reply-To: <87ikx0mk4c.fsf@posteo.net> (message from Philip Kaludercic on Sat, 20 Jul 2024 10:29:55 +0000) 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:289039 Archived-At: > From: Philip Kaludercic > Cc: mekeor@posteo.de, monnier@iro.umontreal.ca, 71503@debbugs.gnu.org > Date: Sat, 20 Jul 2024 10:29:55 +0000 > > >> > > The difference is that pcase-lambda doesn't do case-distinction, but > >> > > just pattern matching/destruncting. So if the pattern-matching fails, > >> > > then the variable is just not bound, instead of the entire expression > >> > > falling back to returning no value/nil. I am guessing you wanted to > >> > > have something like Scheme's `case-lambda'[0]? Or we could clarify this > >> > > point in the docstring. > >> > > >> > Would you mind suggesting a clarification for the doc string (and the > >> > ELisp manual as well)? > > Sorry, I didn't realise you were pining me. I was thinking of something > like > > diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el > index 5a7f3995311..f546ba34c7c 100644 > --- a/lisp/emacs-lisp/pcase.el > +++ b/lisp/emacs-lisp/pcase.el > @@ -241,9 +241,10 @@ pcase-exhaustive > ;;;###autoload > (defmacro pcase-lambda (lambda-list &rest body) > "Like `lambda' but allow each argument to be a pattern. > -I.e. accepts the usual &optional and &rest keywords, but every > -formal argument can be any pattern accepted by `pcase' (a mere > -variable name being but a special case of it)." > +I.e. accepts the usual &optional and &rest keywords, but every formal > +argument can be any pattern accepted by `pcase' (a mere variable name > +being but a special case of it). Keep in mind that BODY is always > +evaluated, regardless of whether the argument-patterns match or not." > (declare (doc-string 2) (indent defun) > (debug (&define (&rest pcase-PAT) lambda-doc def-body))) > (let* ((bindings ()) > > but now I notice that `pcase-let*' documents that all expressions should > match, > > Each EXP should match its respective PATTERN (i.e. be of structure > compatible to PATTERN); a mismatch may signal an error or may go > undetected, binding variables to arbitrary values, such as nil. > > Since `pcase-lambda' inherits these semantics we would have to propagate > this promise -- or be more specific about what happens, e.g. binding > values to nil. Thanks. If this still can be fixed by some documentation changes, I'd prefer to do that.