GNU bug report logs -
#59887
pcase vs. pcase-let: Underscore in backquote-style patterns
Previous Next
Reported by: hokomo <hokomo <at> airmail.cc>
Date: Wed, 7 Dec 2022 17:10:02 UTC
Severity: normal
Done: Michael Heerdegen <michael_heerdegen <at> web.de>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 59887-done <at> debbugs.gnu.org (full text, mbox):
> 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
This bug report was last modified 2 years and 240 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.