unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Marco Antoniotti <marcoxa@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Bruno Barbier <brubar.cs@gmail.com>, 70597@debbugs.gnu.org
Subject: bug#70597: Problem in pcase-let?
Date: Sun, 28 Apr 2024 17:38:30 +0200	[thread overview]
Message-ID: <CAKmY7cVY8m8dKU-rJZx+Mz8=WDEBSHAZKGqbUeg3-n-NRY2s9Q@mail.gmail.com> (raw)
In-Reply-To: <jwvwmohikiw.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]

Thank you all for the replies.

Let me just answer the destructuring-bind comment by Stefan (I am answering
to his last email).  The previous ones are somewhat answered here as well.

In some sense, yes.  I kind of want destructuring-bind.  It is, IMHO,
unfortunate that ELisp does not have it and that we don't have
cl-destructuring-bind either; lower level beast than matching, but useful.

As per the pcase-let, I still think that the name and/or its behavior are
confusing because of expectations about how a pattern matcher usually
works.  Of course you have the problems with "no matching" but that
semantics can be dealt with separately, without surprising the user (at
least me).  And note that this is, IMHO, "surprising".

*(pcase-let (`(foo bar ,x) '(bar foo 42)) x)*

IMHO, this should either return nil or signal an error.  With
destructuring-bind* I would write (assuming indifference variables):

*(destructuring-bind* (_ _ x) x)*

All the best

Marco


On Sun, Apr 28, 2024 at 5:22 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > Pattern matchers do ... pattern matching.
>
> `pcase` is a pattern matcher.
> `pcase-let` is not: it performs "destructuring bindings".
>
> If you want to test if a pattern matches, then you want to use `pcase`
> or `pcase-exhaustive`, and not `pcase-let`.
>
> If you want a "one-branch `pcase-exhaustive` with a let-style notation",
> we could add such a thing of course, but I'd first like to see some
> evidence that it's useful in practice.
>
>
>         Stefan
>
>

-- 
Marco Antoniotti
Somewhere over the Rainbow

[-- Attachment #2: Type: text/html, Size: 2610 bytes --]

  reply	other threads:[~2024-04-28 15:38 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
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 [this message]
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='CAKmY7cVY8m8dKU-rJZx+Mz8=WDEBSHAZKGqbUeg3-n-NRY2s9Q@mail.gmail.com' \
    --to=marcoxa@gmail.com \
    --cc=70597@debbugs.gnu.org \
    --cc=brubar.cs@gmail.com \
    --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).