From: Michael Heerdegen <michael_heerdegen@web.de>
To: hokomo <hokomo@airmail.cc>
Cc: 59887-done@debbugs.gnu.org
Subject: bug#59887: pcase vs. pcase-let: Underscore in backquote-style patterns
Date: Tue, 13 Dec 2022 02:17:56 +0100 [thread overview]
Message-ID: <87edt42jaz.fsf@web.de> (raw)
In-Reply-To: <87pmco8nyc.fsf@airmail.cc> (hokomo@airmail.cc's message of "Mon, 12 Dec 2022 19:26:28 +0100")
hokomo <hokomo@airmail.cc> writes:
> 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.
> <https://www.gnu.org/software/emacs/manual/html_node/elisp/Destructuring-with-pcase-Patterns.html>
That says:
| The macros described in this section use ‘pcase’ patterns to perform
| destructuring binding. The condition of the object to be of compatible
| structure means that the object must match the pattern, because only
| then the object’s subfields can be extracted. For example:
|
| (pcase-let ((`(add ,x ,y) my-list))
| (message "Contains %S and %S" x y))
|
| does the same as the previous example, except that it directly tries to
| extract ‘x’ and ‘y’ from ‘my-list’ without first verifying if ‘my-list’
| is a list which has the right number of elements and has ‘add’ as its
| first element. The precise behavior when the object does not actually
| match the pattern is undefined, although the body will not be silently
| skipped: either an error is signaled or the body is run with some of the
| variables potentially bound to arbitrary values like ‘nil’.
That explains the same thing quite broadly. Maybe you did not notice
the implications when you first read it? I dunno, I'm not that good in
writing documentation, but I can't find something to add from what we
had discussed that would not be redundant.
Or should we maybe just warn about the possible pitfall a bit more
offensively?
Michael.
next prev parent reply other threads:[~2022-12-13 1:17 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
2022-12-13 1:17 ` Michael Heerdegen [this message]
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=87edt42jaz.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=59887-done@debbugs.gnu.org \
--cc=hokomo@airmail.cc \
/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.