From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel 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 Message-ID: <87eglrmdmp.fsf@petton.fr> References: <20150602201956.22733.21800@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1433449121 21065 80.91.229.3 (4 Jun 2015 20:18:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Jun 2015 20:18:41 +0000 (UTC) Cc: Nicolas Petton , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 04 22:18:27 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z0bam-0006v7-Aa for ged-emacs-devel@m.gmane.org; Thu, 04 Jun 2015 22:18:20 +0200 Original-Received: from localhost ([::1]:43929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0bal-0003uN-QW for ged-emacs-devel@m.gmane.org; Thu, 04 Jun 2015 16:18:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0bah-0003th-Td for emacs-devel@gnu.org; Thu, 04 Jun 2015 16:18:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0bad-0006pd-Qk for emacs-devel@gnu.org; Thu, 04 Jun 2015 16:18:15 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:41296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0bad-0006pZ-J5 for emacs-devel@gnu.org; Thu, 04 Jun 2015 16:18:11 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8E72521D30 for ; Thu, 4 Jun 2015 16:18:08 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Thu, 04 Jun 2015 16:18:10 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=ykgwESyuQJyW5Ao+vNOu4l0AudI=; b=oOAtZ VBRXFCYaLbT1B8jBs+qN8PX4MzZlQ7+qkh9nO5F3/uMuz65cGcC/cMkGhv3ycnEV h7YBXkDwvDZULUl62tcZhjLSwE/osZwrJtKSDFtv6wbn7VYmcs7b2WsRrKrYlbNP wh5pQtTRgQeyvMuVvb6XWCTFUFR9Bx/606ai/U= X-Sasl-enc: 89uxevDT6d6iydE6hpIm9cVgPOMJ6834F6Jv4Jnaicz5 1433449088 Original-Received: from blueberry (unknown [80.216.74.58]) by mail.messagingengine.com (Postfix) with ESMTPA id BEC1CC00028; Thu, 4 Jun 2015 16:18:07 -0400 (EDT) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187025 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 =2D-=20 Nicolas Petton http://nicolas-petton.fr --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJVcLJ+AAoJECM1h6R8IHkQZ+UIAM70FdTEBcb0koI5lYWi0hx3 RjAbLmzqTRI8IktzpD/10g+dptmsWAdH8eOBWI91XRxNyxc10B6cZ+tuk3Dub6yW ClYNCHSEaNsIuVeiVhqOiBLSLM7jXYW8QANGGMrZWVzcCEDp5dda6XXJmixGXrSe 2Nh4zKJcQA4MuExxpx1Ai1ARsNCOuJKYsEIUui9EGdV4furuDsiocLWHs7f3NHHp V/9iON6yEX2d7/PQxNTnOC0EsSc5Thjxf1Cp/DV8uNuqyEjpjDDYNSHTsqD6es7z TyEhjQncLct1lfCn3XU/YdU+DmtR+YFp7yyyHInT177SCyjcw7y3OG+FXUffBjc= =ueTL -----END PGP SIGNATURE----- --=-=-=--