From: Tassilo Horn <tsdh@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: emacs-devel@gnu.org
Subject: Re: pcase-dolist
Date: Wed, 08 Jul 2015 20:26:30 +0200 [thread overview]
Message-ID: <87oajmld49.fsf@gnu.org> (raw)
In-Reply-To: <87y4iqh7x0.fsf@web.de> (Michael Heerdegen's message of "Wed, 08 Jul 2015 19:32:27 +0200")
Michael Heerdegen <michael_heerdegen@web.de> writes:
>> It could also skip those elements that don't match
>
> That's what I had expected without thinking too much about it. But I
> agree that we would end with something different.
I also think that `pcase-let' and `pcase-dolist' are pretty confusing.
For example,
(pcase-let ((`(,w ,x ,y ,z) '(1 2 3)))
(message "%s %s %s %s" w x y z))
prints "1 2 3 nil" although the pattern when used in `pcase' wouldn't
match that list but only 4-element lists. So a pcase pattern has
different semantics depending on whether it is used in `pcase' or
`pcase-let' or `pcase-dolist' which doesn't feel right.
I'd prefer if `pcase-let' would signal an error if some pattern doesn't
match. Same for `pcase-dolist' with its current semantics. IMHO, the
code above clearly says that the programmer expected to destructure
4-element lists so an error signaling that the expectation is wrong
sounds right.
>> > Anyway, an idea that came to my mind more than once: `when-let',
>> > `if-let' should really be `pcase-when-let' , `pcase-if-let'. They
>> > would be much more useful than the plain versions I think.
>>
>> Yes, feel free to change them that way.
>
> Though, just changing them would break existing code (the current
> versions are about boolean values, the pcase versions would be about
> pattern matching).
So why not have both?
Bye,
Tassilo
next prev parent reply other threads:[~2015-07-08 18:26 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 12:20 pcase-dolist Michael Heerdegen
2015-07-08 13:54 ` pcase-dolist Stefan Monnier
2015-07-08 17:32 ` pcase-dolist Michael Heerdegen
2015-07-08 18:26 ` Tassilo Horn [this message]
2015-07-08 21:27 ` pcase-dolist Stefan Monnier
2015-07-09 6:05 ` pcase-dolist Tassilo Horn
2015-07-09 9:55 ` pcase-dolist Thierry Volpiatto
2015-07-09 10:17 ` pcase-dolist Tassilo Horn
2015-07-09 12:19 ` pcase-dolist Thierry Volpiatto
2015-07-09 13:34 ` pcase-dolist Tassilo Horn
2015-07-09 13:40 ` pcase-dolist Thierry Volpiatto
2015-07-09 19:26 ` pcase-dolist Stefan Monnier
2015-07-09 20:27 ` pcase-dolist Michael Heerdegen
2015-07-10 18:51 ` pcase-dolist Stefan Monnier
2015-10-12 11:27 ` pcase-setq (was: pcase-dolist) Michael Heerdegen
2015-10-12 11:54 ` pcase-setq Michael Heerdegen
2015-10-12 12:01 ` pcase-setq (was: pcase-dolist) Nicolas Petton
2015-10-12 12:36 ` pcase-setq Michael Heerdegen
2015-10-12 12:49 ` Semantic of pcase `seq' and `map' patterns (was: pcase-setq) Michael Heerdegen
2015-10-12 13:41 ` Semantic of pcase `seq' and `map' patterns Michael Heerdegen
2015-10-12 13:55 ` Nicolas Petton
2015-10-12 14:02 ` Michael Heerdegen
2015-10-17 12:21 ` Michael Heerdegen
2015-10-17 13:31 ` Nicolas Petton
2015-10-12 13:50 ` Semantic of pcase `seq' and `map' patterns (was: pcase-setq) Nicolas Petton
2015-10-13 0:59 ` pcase-setq Stefan Monnier
2015-10-13 13:52 ` pcase-setq Michael Heerdegen
2015-10-13 14:02 ` pcase-setq Michael Heerdegen
2015-10-13 15:52 ` pcase-setq Michael Heerdegen
[not found] ` <jwvfv1eboo8.fsf-monnier+emacs@gnu.org>
[not found] ` <87d1wh36as.fsf@web.de>
2015-10-14 15:49 ` pcase-setq Stefan Monnier
2015-07-10 14:44 ` pcase-dolist Tassilo Horn
2015-07-10 19:04 ` pcase-dolist Stefan Monnier
2015-07-08 19:44 ` pcase-dolist Artur Malabarba
2015-07-08 20:50 ` pcase-dolist Michael Heerdegen
-- strict thread matches above, loose matches on Subject: below --
2014-07-11 10:35 pcase-dolist Sebastian Wiesner
2014-07-11 13:47 ` pcase-dolist Stefan Monnier
2014-07-11 13:50 ` pcase-dolist Sebastian Wiesner
2014-07-11 14:14 ` pcase-dolist Stefan Monnier
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=87oajmld49.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=michael_heerdegen@web.de \
/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).