From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier 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 00:15:05 -0400 Message-ID: References: <20150510182502.23307.63648@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1431317735 3269 80.91.229.3 (11 May 2015 04:15:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 May 2015 04:15:35 +0000 (UTC) Cc: Nicolas Petton To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 11 06:15: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 1Yrf7l-0002nq-EF for ged-emacs-devel@m.gmane.org; Mon, 11 May 2015 06:15:25 +0200 Original-Received: from localhost ([::1]:35399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrf7j-0004tW-UY for ged-emacs-devel@m.gmane.org; Mon, 11 May 2015 00:15:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrf7X-0004tC-5u for emacs-devel@gnu.org; Mon, 11 May 2015 00:15:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yrf7S-0008Sk-5b for emacs-devel@gnu.org; Mon, 11 May 2015 00:15:11 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:20776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrf7S-0008Qv-2F for emacs-devel@gnu.org; Mon, 11 May 2015 00:15:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAGvvdVRFpYts/2dsb2JhbAA3gVOhb4EIgXYBBVYjEAs0EhQYDapIi3YlDANGA4M+AwNPgx4Eo2OEWA X-IPAS-Result: AgUFAGvvdVRFpYts/2dsb2JhbAA3gVOhb4EIgXYBBVYjEAs0EhQYDapIi3YlDANGA4M+AwNPgx4Eo2OEWA X-IronPort-AV: E=Sophos;i="5.11,557,1422939600"; d="scan'208,217";a="119112602" Original-Received: from 69-165-139-108.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.139.108]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 May 2015 00:15:05 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 5478AAE36F; Mon, 11 May 2015 00:15:05 -0400 (EDT) In-Reply-To: (Nicolas Petton's message of "Sun, 10 May 2015 18:25:03 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:186392 Archived-At: > + (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. 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). - 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. > +(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. > + (push `(app (seq--reverse-args #'seq--nested-elt > + (reverse (cons ,index ',nested-indexes))) > + ,name) This reverse plus seq--reverse-args business seems hideously inefficient. Why do you need that? Stefan