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: pcase-dolist Date: Wed, 08 Jul 2015 09:54:43 -0400 Message-ID: References: <87wpyaet7r.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436363716 11465 80.91.229.3 (8 Jul 2015 13:55:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jul 2015 13:55:16 +0000 (UTC) Cc: Emacs Development To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 08 15:55:08 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 1ZCpoO-00045K-G9 for ged-emacs-devel@m.gmane.org; Wed, 08 Jul 2015 15:54:56 +0200 Original-Received: from localhost ([::1]:35233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCpoO-0008Bh-0V for ged-emacs-devel@m.gmane.org; Wed, 08 Jul 2015 09:54:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCpoK-0008Bc-Fy for emacs-devel@gnu.org; Wed, 08 Jul 2015 09:54:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCpoE-0007r6-Cz for emacs-devel@gnu.org; Wed, 08 Jul 2015 09:54:52 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:41744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCpoE-0007og-8Y for emacs-devel@gnu.org; Wed, 08 Jul 2015 09:54:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AxFgA731xV/2cGNJ1cgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAVYjBQsLNBIUGA0kiDcIzyMBAQEBBgIBH4s6hQUHhC0Fi0STU4ZpjwQjgWaCLiKCeAEBAQ X-IPAS-Result: A0AxFgA731xV/2cGNJ1cgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAVYjBQsLNBIUGA0kiDcIzyMBAQEBBgIBH4s6hQUHhC0Fi0STU4ZpjwQjgWaCLiKCeAEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="129520946" Original-Received: from 157-52-6-103.cpe.teksavvy.com (HELO pastel.home) ([157.52.6.103]) by ironport2-out.teksavvy.com with ESMTP; 08 Jul 2015 09:54:44 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id DF43F60647; Wed, 8 Jul 2015 09:54:43 -0400 (EDT) In-Reply-To: <87wpyaet7r.fsf@web.de> (Michael Heerdegen's message of "Wed, 08 Jul 2015 14:20:40 +0200") 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:187773 Archived-At: > (pcase-dolist ((and x (pred < 0)) '(-1 0 1 2)) > (message "%s" x)) > prints all members of the sequence. What would you want it to do? I think it'd be the only other meaningful behavior would be to signal an error, but that would rarely be useful. It could also skip those elements that don't match, but then it'd be more like a "filter" loop so it would need another name. And it would then be very tempting/desirable to make it possible to provide a chunk of code to use when the pattern doesn't match. So we'd end up with something like (pcase-newdolist LIST (PAT1 . BODY1) (PAT2 . BODY2) ...) which would just be a shorthand for (dolist (x LIST) (pcase x (PAT1 . BODY1) (PAT2 . BODY2) ...)) > Apart from the question whether this semantic is useful: with the > current semantic, a name that includes "case" is irritating considering > such a behavior. I completely read the name as "-dolist" but you have a good point: the prefix has "case" in its name, which makes it misleading. > Maybe "pdolist" (and "plet", "plet*") would be better names? For pcase-dolist, I think the right name to use is `dolist'. > Anyway, an idea that came to my mind more than once: `when-let', > `if-let' should really be `pcase-when-let' , `pcase-if-let'. They would > be much more useful than the plain versions I think. Yes, feel free to change them that way. > Then `pcase-dolist' could be reimplemented using `pcase-when-let'. Not sure what you mean: the current semantics of pcase-dolist is the right one IMNSHO. Stefan