From: Bruno Barbier <brubar.cs@gmail.com>
To: Marco Antoniotti <marcoxa@gmail.com>, 70597@debbugs.gnu.org
Subject: bug#70597: Problem in pcase-let?
Date: Sat, 27 Apr 2024 18:11:41 +0200 [thread overview]
Message-ID: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> (raw)
In-Reply-To: <CAKmY7cWtrOZ5gCgELraucvznb+6+72mZpGHoMdcKeEeuAwL3sQ@mail.gmail.com>
Hi Marco,
I'm not a maintainer but let me try to explain; I'm sure someone will
correct me if I'm wrong.
In short: not a bug.
If I read your examples correctly, your problem could be reduced to this:
(using org mode syntax, I hope it's ok):
#+begin_src elisp
(pcase-let
((`(A *,c . ,r) '(A *1 2 3)))
(list c r))
#+end_src
#+RESULTS:
: (2 (3))
#+begin_src elisp
(pcase-let
((`(A *,c . ,r) '(B *1 2 3)))
(list c r))
#+end_src
#+RESULTS:
: (2 (3))
#+begin_src elisp
(pcase '(A *1 2 3)
(`(B *,c . ,r) (list c r)))
#+end_src
#+RESULTS:
: nil
The pcase-let documentation (describe-function 'pcase-let) says this:
| 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.
Both of your pcase-let examples are actually undefined, because the
patterns don't match in *both* cases. pcase-let works as documented:
it did bind some variables to arbitrary values.
That one matches (note the space between * and 1):
#+begin_src elisp
(pcase-let
((`(A * ,c . ,r) '(A * 1 2 3)))
(list c r))
#+end_src
#+RESULTS:
: (1 (2 3))
That one doesn't match either (replacing * with WORD), but same
result that your 2 pcase-let examples:
#+begin_src elisp
(pcase-let
((`(A *,c . ,r) '(A WORD1 2 3)))
(list c r))
#+end_src
#+RESULTS:
: (2 (3))
Note that *1 is one symbol whose name is "*1". Your pattern `(*,c) is
looking for the symbol whose name is "*", followed by the value for c.
You may test your pattern, manually binding c to some value, to see
that you get a list containing 2 values:
#+begin_src elisp
(let ((c 1))
`(*,c))
#+end_src
#+RESULTS:
: (* 1)
Hoping this helps,
Bruno
next prev parent reply other threads:[~2024-04-27 16:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 18:00 bug#70597: Problem in pcase-let? Marco Antoniotti
2024-04-27 16:11 ` Bruno Barbier [this message]
2024-04-27 22:28 ` Marco Antoniotti
2024-04-28 10:01 ` Bruno Barbier
2024-04-28 10:07 ` Ihor Radchenko
2024-04-28 10:18 ` Eli Zaretskii
2024-04-28 15:22 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-28 15:38 ` Marco Antoniotti
2024-04-28 17:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-28 18:22 ` Marco Antoniotti
2024-04-28 21:08 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-02 9:23 ` Eli Zaretskii
2024-05-02 11:06 ` Marco Antoniotti
2024-05-04 11:35 ` Eli Zaretskii
2024-05-04 12:06 ` Marco Antoniotti
2024-05-04 15:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 8:49 ` Marco Antoniotti
2024-05-04 15:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=662d23bf.050a0220.a4e2f.3f45@mx.google.com \
--to=brubar.cs@gmail.com \
--cc=70597@debbugs.gnu.org \
--cc=marcoxa@gmail.com \
/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).