From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: 16567@debbugs.gnu.org, Leo Liu <sdl.web@gmail.com>
Subject: bug#16567: 24.3.50; pcase should signal an error if no case matches
Date: Wed, 10 Sep 2014 13:26:14 -0400 [thread overview]
Message-ID: <jwvd2b3iefx.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <m2mwa7tuqv.fsf@gmail.com> (Helmut Eller's message of "Wed, 10 Sep 2014 16:28:40 +0200")
>> I'm open to other suggestions, and `pcasex' is not unacceptable, so
>> I think we're closing in.
> pcase* looks less exotic that pcasex; though it's harder to type.
> BTW, I find it surprising that this doesn't signal an error:
> (pcase-let ((`(1 ,x) '("foo")))
> x)
Indeed, the semantics of pcase-let is a bit subtle: rather than use the
pattern as a filter to decide whether to match or not, it just assumes
that the match is a success and accesses the data accordingly.
So the above expands to something morally equivalent to
(let ((x (cadr '("foo")))) x)
> But I suspect that "it's not an option" to change pcase-let.
I don't think backward compatibility is as much of an issue for
pcase-let, but the motivation for this semantics was efficiency, and
this is still as valid as ever, AFAIK.
For single-branch pcase-let, the alternative
(pcase-exhaustive '("foo")
(`(1 ,x) x))
is a good replacement to get the semantics you expect. But admittedly,
for if you have several bindings in your pcase-let, the equivalent
pcase-exhaustive can become inconvenient.
Stefan
next prev parent reply other threads:[~2014-09-10 17:26 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-27 9:22 bug#16567: 24.3.50; pcase should signal an error if no case matches Helmut Eller
2014-01-27 10:27 ` Daimrod
2014-01-27 11:56 ` Helmut Eller
2014-01-27 12:23 ` Daimrod
2014-09-08 18:27 ` Leo Liu
2014-09-08 19:19 ` Stefan Monnier
2014-09-08 20:58 ` Helmut Eller
2014-09-09 0:41 ` Stefan Monnier
2014-09-10 0:02 ` Leo Liu
2014-09-10 2:26 ` Stefan Monnier
2014-09-10 2:52 ` Leo Liu
2014-09-10 5:32 ` Josh
2014-09-10 6:18 ` Helmut Eller
2014-09-10 13:17 ` Stefan Monnier
2014-09-10 14:28 ` Helmut Eller
2014-09-10 17:26 ` Stefan Monnier [this message]
2014-09-10 14:33 ` Leo Liu
2014-09-10 16:54 ` Glenn Morris
2014-09-10 17:54 ` Stefan Monnier
2014-09-12 2:35 ` Leo Liu
2014-09-12 17:15 ` Stefan Monnier
2014-09-13 0:29 ` Leo Liu
2014-09-13 3:10 ` Stefan Monnier
2014-09-13 4:57 ` Leo Liu
2014-09-13 15:01 ` Stefan Monnier
2014-09-13 17:25 ` Leo Liu
2014-09-10 17:39 ` Richard Stallman
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=jwvd2b3iefx.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=16567@debbugs.gnu.org \
--cc=eller.helmut@gmail.com \
--cc=sdl.web@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).