unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: mekeor@posteo.de, Eli Zaretskii <eliz@gnu.org>, 71503@debbugs.gnu.org
Subject: bug#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected
Date: Sun, 21 Jul 2024 12:39:00 +0000	[thread overview]
Message-ID: <87sew2ly1n.fsf@posteo.net> (raw)
In-Reply-To: <jwvy15w5fic.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 20 Jul 2024 10:06:18 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>  (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 ())
>
> 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)".

Another confusing behaviour that we should document is that in

(let ((a nil))
  (funcall
   (pcase-lambda (a (and (guard a) b))
     (list a b))
   1 2))

I would expect that the (guard a) would use the nil binding from the
`let' form, but instead it is ignored and b is bound to 2.  I am not
sure if this is related to the "destructing" point or not.

>
>
>         Stefan
>

-- 
	Philip Kaludercic on peregrine





  reply	other threads:[~2024-07-21 12:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  8:40 bug#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected Mekeor Melire
2024-06-14  8:42 ` Philip Kaludercic
2024-06-14 16:08   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22  8:37   ` Eli Zaretskii
2024-07-06  7:38     ` Eli Zaretskii
2024-07-20  9:42       ` Eli Zaretskii
2024-07-20 10:29         ` Philip Kaludercic
2024-07-20 10:46           ` Eli Zaretskii
2024-07-21 11:17             ` Philip Kaludercic
2024-07-21 13:33               ` Mekeor Melire
2024-07-20 14:06           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-21 12:39             ` Philip Kaludercic [this message]
2024-07-21 13:51               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-04  7:58                 ` Eli Zaretskii
2024-08-04 14:54                   ` Philip Kaludercic
2024-08-04 15:08                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sew2ly1n.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=71503@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mekeor@posteo.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).