From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected Date: Sun, 21 Jul 2024 11:17:05 +0000 Message-ID: <87zfqbkn9q.fsf@posteo.net> 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> <86r0bocpd6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22052"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mekeor@posteo.de, monnier@iro.umontreal.ca, 71503@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 21 13:18:25 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 1sVUa8-0005QN-Ju for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Jul 2024 13:18:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVUZp-00010P-EF; Sun, 21 Jul 2024 07:18:05 -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 1sVUZk-000108-Fu for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 07:18:03 -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 1sVUZk-0000jf-84 for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 07:18:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sVUZl-0007SX-PD for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 07:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Jul 2024 11:18:01 +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.172156063828625 (code B ref 71503); Sun, 21 Jul 2024 11:18:01 +0000 Original-Received: (at 71503) by debbugs.gnu.org; 21 Jul 2024 11:17:18 +0000 Original-Received: from localhost ([127.0.0.1]:54805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVUZ3-0007Rd-Qa for submit@debbugs.gnu.org; Sun, 21 Jul 2024 07:17:18 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:40137) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVUZ1-0007RP-9H for 71503@debbugs.gnu.org; Sun, 21 Jul 2024 07:17:16 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 21552240029 for <71503@debbugs.gnu.org>; Sun, 21 Jul 2024 13:17:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1721560627; bh=d1mXl20sg7Tvz1u7CW9gmumWDFBhXt7tXcfdHA+24SQ=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=Mb+0aoh8/njkKJr6dPnqrBCJSJDWHQzX2zGL0NqkxLnanxLiWyZF1kZI0SnIo5rea +ZII80lP5F6DyN4k975eTYG4tCLx3hIA+0v78D3Kt4NHfx/dTwA1dofGiPlf+fTccD n60J5puDi2N00W4bo8QeZxSYE7mHs+J5vbmrQ0XXqy+Q+5R50I06fgjVdRr/wFCQ1a U7OXhWmccifL7eKc52Qwf/Gx2R0tTP+u+8YWuaMNLHdCvzhGh+p4iurleF1NwtgVuD Ok1hvwDTIy7x68RnCnC/xWg07EPhLXavufUmvEQmsvYExewM/zYxhbzP1tYxHgiTxe vUV6L31/+jQDA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WRgq61fvZz6tlh; Sun, 21 Jul 2024 13:17:06 +0200 (CEST) In-Reply-To: <86r0bocpd6.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Jul 2024 13:46:45 +0300") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt 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:289069 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> 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. In that case I think it would be better to stick to a warning like the one in `pcase-let*'.. Stefan Monnier writes: [...] > I tend to call "any pattern accepted by `pcase'" a "Pcase pattern". > More importantly, we should refer to `pcase-let` rather than to > `pcase` here and we should likely use the term "destructuring (binding)". What do you think of: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 5a7f3995311..fd6b0c8db5c 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -241,9 +241,14 @@ 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 destructed by `pcase-let' (a mere variable +name being but a special case of it). + +Each argument should match its respective pattern in the parameter +list (i.e. be of a compatible structure); a mismatch may signal an error +or may go undetected, binding arguments to arbitrary values, such as +nil." (declare (doc-string 2) (indent defun) (debug (&define (&rest pcase-PAT) lambda-doc def-body))) (let* ((bindings ()) --=-=-= Content-Type: text/plain > Stefan > -- Philip Kaludercic on peregrine --=-=-=--