bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#70597: Problem in pcase-let?


From: Marco Antoniotti
Subject: bug#70597: Problem in pcase-let?
Date: Sun, 28 Apr 2024 17:38:30 +0200

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]