From: Nicolas Petton <nicolas@petton.fr>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Nicolas Petton <nicolas@petton.fr>, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] map 988d721: Add a pcase pattern for maps and `map-let' based on it
Date: Thu, 04 Jun 2015 22:18:06 +0200 [thread overview]
Message-ID: <87eglrmdmp.fsf@petton.fr> (raw)
In-Reply-To: <jwvbngx1unb.fsf-monnier+emacsdiffs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1628 bytes --]
Stefan Monnier writes:
>> + "pcase pattern matching map elements.
>> +Matches if the object is a map (list, hash-table or array), and
>> +binds values from ARGS to the corresponding element of the map.
>> +
>> +ARGS can be an alist of key/binding pairs of a list of keys."
>
> I think this would benefit from a bit more detail. E.g. you could say
> "ARGS is a list of elements of the form (KEY PAT)" or something
> like that.
Yes, and there's a typo. It should be "[...] or a list of keys.".
>
>> + (seq-map (lambda (elt)
>> + (if (consp elt)
>> + `(app (pcase--flip map-elt ',(car elt)) ,(cdr elt))
>> + `(app (pcase--flip map-elt ',elt) ,elt)))
>> + args))
>
> Hmm... It looks like it's actually elements of the form (KEY . PAT) or
> elements of the form SYMBOL which stands for (SYMBOL . SYMBOL).
Yes, exactly.
> Some alternatives to consider:
> - Use (KEY PAT) instead of (KEY . PAT). This makes the source code
> a bit more concise, so I'm in favor of the (KEY PAT) form.
Why not, I don't have a strong opinion, and I think both would work.
> - Use a plist rather than an alist. I like alists better in general, so
> I'm fine with this choice.
Yes, I think it's better than a plist.
> - let KEY be evaluated rather than having it be quoted. I.e. require
> the programmer to write 'a when looking up the key `a'. It costs an
> extra quote in some/many cases, but does give you extra power.
Do you think it would be worth it? I'm not sure.
Cheers,
Nico
--
Nicolas Petton
http://nicolas-petton.fr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
next prev parent reply other threads:[~2015-06-04 20:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150602201956.22733.21800@vcs.savannah.gnu.org>
[not found] ` <E1YzsfE-0005vH-4d@vcs.savannah.gnu.org>
2015-06-03 1:06 ` [Emacs-diffs] map 988d721: Add a pcase pattern for maps and `map-let' based on it Stefan Monnier
2015-06-04 20:18 ` Nicolas Petton [this message]
2015-06-04 22:39 ` Stefan Monnier
2015-06-05 8:09 ` Nicolas Petton
2015-06-07 18:36 ` Michael Heerdegen
2015-06-08 14:16 ` Stefan Monnier
2015-06-08 15:34 ` Michael Heerdegen
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=87eglrmdmp.fsf@petton.fr \
--to=nicolas@petton.fr \
--cc=emacs-devel@gnu.org \
--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).