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: Semantic of pcase `seq' and `map' patterns (was: pcase-setq) Date: Mon, 12 Oct 2015 15:50:51 +0200 Message-ID: <87wpuskxfo.fsf@petton.fr> References: <87wpyaet7r.fsf@web.de> <87y4iqh7x0.fsf@web.de> <87oajmld49.fsf@gnu.org> <87oajlyif9.fsf@gnu.org> <87a8v53wll.fsf@web.de> <87k2qsxr73.fsf_-_@web.de> <87bnc4mh2q.fsf@petton.fr> <874mhwxne8.fsf_-_@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1444657915 30390 80.91.229.3 (12 Oct 2015 13:51:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Oct 2015 13:51:55 +0000 (UTC) To: Michael Heerdegen , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 12 15:51:46 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 1ZldVx-0005NN-2k for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 15:51:45 +0200 Original-Received: from localhost ([::1]:55506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZldVx-0001qT-2i for ged-emacs-devel@m.gmane.org; Mon, 12 Oct 2015 09:51:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZldVD-00019K-B4 for emacs-devel@gnu.org; Mon, 12 Oct 2015 09:51:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZldVA-000712-0W for emacs-devel@gnu.org; Mon, 12 Oct 2015 09:50:59 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:51436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZldV9-00070m-Hw for emacs-devel@gnu.org; Mon, 12 Oct 2015 09:50:55 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AC24120A73 for ; Mon, 12 Oct 2015 09:50:54 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Mon, 12 Oct 2015 09:50:54 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=JnIEJqhqn018s0b5QAXfiR0pz40=; b=LLeUR nrr4UJHnBQOwHD+YrwhLLLpbhyeKiuvrwrn0iuabCSfdTisNhp4Dk+e2ODXfCoDs exf4+GHbp1Ql+e6xMo3lcMVWsQMRD/70EnoNRHoXbosS0BRcETs2dSMI5L+qXm5q NjiL16jQFqAHIqZ7wj1ZlHDB7BHIsAfS4i2Pwg= X-Sasl-enc: lWpvseKUcbAro2L/QH/UMO4MEfBzFBTPdwzHbqpuJV/l 1444657854 Original-Received: from blueberry (brc29-2-88-162-37-238.fbx.proxad.net [88.162.37.238]) by mail.messagingengine.com (Postfix) with ESMTPA id ECE42C00022; Mon, 12 Oct 2015 09:50:53 -0400 (EDT) In-Reply-To: <874mhwxne8.fsf_-_@web.de> User-Agent: Notmuch/0.19 (http://notmuchmail.org) Emacs/25.0.50.7 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 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:191334 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: > After reading the doc of the `seq' pcase pattern: > > --8<---------------cut here---------------start------------->8--- > -- (seq &rest ARGS) > > pcase pattern matching sequence elements. > Matches if the object is a sequence (list, string or vector), and > binds each element of ARGS to the corresponding element of the > sequence. > --8<---------------cut here---------------end--------------->8--- > > it was not obvious to me how this example would look like using pcase - > especially, what "are" the "ARGS"? > > AFAIU the "ARGS" are just normal (pcase) patterns - they are not limited > to variables, and matching can fail for them as well even if the number > of sequence arguments would match. > > I think the semantic would be better described like this: > > --8<---------------cut here---------------start------------->8--- > -- (seq &rest PATTERNS) > > pcase pattern matching sequence elements. > Matches if the object is a sequence (list, string or vector), and > each PATTERN matches the corresponding element of the > sequence. > --8<---------------cut here---------------end--------------->8--- > > Does that make sense? Likewise `map', I guess. Yes, it does. You could for example do: (pcase [1 2 3 4] ... ((seq (pred oddp) (pred evenp)) 'matched) ...) I will update the documentation, thanks! Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: GPGTools - http://gpgtools.org iQEcBAEBCAAGBQJWG7q7AAoJECM1h6R8IHkQDM4IAIN/P7JZTaPGNKN1w6LeuhOV TMPUdzxuTJTggvHaYgHBuXrL1Hzrm7eiXJhBuddiNsdjRQQlFCbu1/H0HTWs2UVj NWZj6P0A6g/afSpW60WLC3QA+P13wJ05V+ekcGhiszpbFg26PHfPnzI9K3VdnVHO 2Oyf91Eo968DLXc41T23gawG2KNv2zk5+aan1kM6b2i0RTjCKUIUK3xWHG/I2gNk gIFO1pbaaC5QYk3oEvv9aIYcaoe3PYtmHo547FvCOCMnVK8tblcx6GNHwRv+oUKP CTczP+0y1rB5D6/hKAqUzc7T+LChKNHA2Qm2NRL+pajlHbhY38QWxe9wYacrzqI= =j5K0 -----END PGP SIGNATURE----- --=-=-=--