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] master 387e1e1: New version of `seq-let' based on a pcase pattern Date: Mon, 11 May 2015 15:42:39 +0200 Message-ID: <874mnjdycw.fsf@petton.fr> References: <20150510182502.23307.63648@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 1431352565 29884 80.91.229.3 (11 May 2015 13:56:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 May 2015 13:56:05 +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 Mon May 11 15:55:55 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 1YroBQ-0004YI-H2 for ged-emacs-devel@m.gmane.org; Mon, 11 May 2015 15:55:48 +0200 Original-Received: from localhost ([::1]:37566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YroBP-0003P9-Eg for ged-emacs-devel@m.gmane.org; Mon, 11 May 2015 09:55:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrnyn-0005tM-H5 for emacs-devel@gnu.org; Mon, 11 May 2015 09:42:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yrnyk-0001pR-M7 for emacs-devel@gnu.org; Mon, 11 May 2015 09:42:45 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:55608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrnyk-0001pC-Ed for emacs-devel@gnu.org; Mon, 11 May 2015 09:42:42 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 968242019A for ; Mon, 11 May 2015 09:42:41 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Mon, 11 May 2015 09:42:41 -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=3qNF3WZO02EjzdpaQlxgynudsjc=; b=dx6r1 Qk3HZWZFLEHbboFJCmjBM4IF9buHs5WO4Jczn1viRsw72XBLMR+XwHR4W9gIWu/w K+8IlKHTpqvz33UyfVerWKf6VYovaHIaIuiFKFUficxXDA/sXBaTwZKZV/ypBcmD VfSVC/mZWKXyXnkQ/gEVygXvFSIvD0TxgxMs50= X-Sasl-enc: oeLooizZKxM5NpPNmkUukR1pz5BTxMYFwfQ0Tk3keLY7 1431351761 Original-Received: from blueberry (unknown [92.139.225.158]) by mail.messagingengine.com (Postfix) with ESMTPA id DF62368011D; Mon, 11 May 2015 09:42:40 -0400 (EDT) In-reply-to: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:186399 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: >> + (pcase-defmacro seq (bindings) >> + `(and ,@(seq--make-pcase-bindings bindings))) > > If you put a docstring in there, it will appear in "C-h f pcase RET", so > you can use it to document the particular format you support. Great, I'll do that. > Also I see the following problems: > - You only accept the form (seq ) rather than (seq > ...), so typical cases will have to use (seq (a b)) instead > (seq a b). Yes. My idea of it was that you bind a sequence like the following: (seq [a b [c d]]) Or did you have something else in mind? > - The above pcase pattern doesn't check that it's indeed a `seq'. > You should add a (pred seq-p). It will automatically be optimized > away in `pcase-let', but is indispensable for the `pcase' situation to > do the right thing. Ok, I'll do that. > >> +(defun seq--make-pcase-bindings (args &optional bindings nested-indexes) > [...] >> + (seq-doseq (name args) >> + (unless rest-marker >> + (pcase name >> + ((pred seq-p) > > IIUC, this means that (pcase-let (((seq a (seq b c)) )) ) > will bind the `seq' variable to the first element of the nested sequence > (and `a' to the second and `b' to the third), whereas I think it should > bind `b' to the first element of the nested sequence (which is what > would happen if you simply removed this branch of this `pcase'). > I think removing this case will also remove the need for > seq--nested-elt. But then how can I have `seq-let' work the way it did until now? For instance: (seq-let [a [b [c]]] my-vector ...) >> + (push `(app (seq--reverse-args #'seq--nested-elt >> + (reverse (cons ,index ',neste= d-indexes))) >> + ,name) > > This reverse plus seq--reverse-args business seems > hideously inefficient. Why do you need that? because of the way the `app' pattern works. Or maybe I'm missing something? 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 iQEcBAEBAgAGBQJVULHPAAoJECM1h6R8IHkQw3AH/R64NTo+ZFt4byUvypQgfLip Dan4Zq9nfn98XvZYo44a+aOGmzwcpkWcs/Zsf0NY0bSdCy+yA0bBNkygBpI5CxEP PDO/xKWVxrv7sR2Klyn43d6d1ApDTxex18l9ClgT+/kdbnIW/4k2Hzo283L9QYr9 QU+mGK85JtfUL+qKpQ3+TKsrav+1/JsPkKQiK5eBaIhthHlLqMzbcDvbf+ZH13rw ihBnc5sOlK8qczFRVVBEtTQUNMvinkBUAeKSc2aYLdoWQh8JrbCTKl9FwnfRyT62 KgynAfulsexLzlMOuMgVl82o2aej+/UHXh0JTm9SRrFWTF4v3xiv2dSY4UvLtvg= =oDYt -----END PGP SIGNATURE----- --=-=-=--