From: hokomo <hokomo@airmail.cc>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 59887-done@debbugs.gnu.org
Subject: bug#59887: pcase vs. pcase-let: Underscore in backquote-style patterns
Date: Mon, 12 Dec 2022 19:26:28 +0100 [thread overview]
Message-ID: <87pmco8nyc.fsf@airmail.cc> (raw)
In-Reply-To: <87v8mhmj26.fsf@web.de>
> Note this part of the `pcase-let' documentation string:
>
> | Each EXP should match (i.e. be of compatible structure) to its
> | respective PATTERN; a mismatch may signal an error or may go
> | undetected, binding variables to arbitrary values, such as
> nil.
>
> Your first case is invalid because the pattern doesn't match the
> value.
> Here it goes undetected and bindings get established.
I see! That clarifies the behavior I was seeing.
> This behavior is not perfect, but AFAIR it has been preferred
> over the
> less efficient code that better checks would mean. So it's the
> programmer's task to use only matching patterns. This is not
> really a
> restriction because `pcase-let' is intended to create bindings,
> not for
> testing whether a pattern matches some value.
I suppose that's a fair tradeoff.
> This idea had been discussed in the past. It had some votes but
> it had
> been decided not to implement such a feature because it would
> not really
> fit into the existing semantics, just for the sake of leaving
> out one
> ",". So I'm afraid I don't think we will change this.
Right, it doesn't seem like such a huge win now that I understand
that the behavior of pcase-let was according to its specification
and there was no inconsistency to begin with. It would maybe make
the code a little bit easier to read in certain cases, but I can
see your point.
> I think the current behavior can be understood and explained
> from the
> documentation quite well. If you can point to something
> concrete
> missing, please elaborate, and we can reopen this report.
Your quote above made everything clear, but I completely missed it
since I was reading the Emacs Lisp manual's explanation [1] rather
than pcase-let's docstring. Maybe it would be beneficial to
include the above quote in the manual as well.
[1]
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Destructuring-with-pcase-Patterns.html>
Thanks!
hokomo
next prev parent reply other threads:[~2022-12-12 18:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 16:28 bug#59887: pcase vs. pcase-let: Underscore in backquote-style patterns hokomo
2022-12-09 2:57 ` Michael Heerdegen
2022-12-12 2:50 ` Michael Heerdegen
2022-12-12 18:26 ` hokomo [this message]
2022-12-13 1:17 ` Michael Heerdegen
2022-12-13 1:19 ` hokomo
2022-12-13 2:21 ` Michael Heerdegen
2022-12-13 2:26 ` hokomo
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmco8nyc.fsf@airmail.cc \
--to=hokomo@airmail.cc \
--cc=59887-done@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.