From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: The poor state of documentation of pcase like things. Date: Sun, 03 Jan 2016 06:17:43 +0100 Message-ID: <87oad3xmvc.fsf@web.de> References: <20151216202605.GA3752@acm.fritz.box> <87io3m60bq.fsf@web.de> <877fk1nnk0.fsf@web.de> <8760zlue3j.fsf@gmail.com> <87vb7kajgv.fsf@web.de> <83y4c9ag06.fsf@gnu.org> <87bn95m9eg.fsf@fencepost.gnu.org> <5686CDFB.2010105@dancol.org> <83fuygcs5g.fsf@gnu.org> <87r3i0l6oq.fsf@fencepost.gnu.org> <87si2fwm38.fsf@web.de> <87y4c7xs8l.fsf@web.de> <92231dbf-1b5f-43ef-8792-fa44d5c4073e@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1451798301 28991 80.91.229.3 (3 Jan 2016 05:18:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 05:18:21 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 03 06:18:13 2016 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 1aFb3U-00014D-UQ for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 06:18:13 +0100 Original-Received: from localhost ([::1]:40505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFb3R-0007Sp-2B for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 00:18:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFb3E-0007Se-N3 for emacs-devel@gnu.org; Sun, 03 Jan 2016 00:17:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFb3B-0001bh-GG for emacs-devel@gnu.org; Sun, 03 Jan 2016 00:17:56 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:37552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFb3B-0001bX-9B for emacs-devel@gnu.org; Sun, 03 Jan 2016 00:17:53 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aFb39-0000ie-TZ for emacs-devel@gnu.org; Sun, 03 Jan 2016 06:17:51 +0100 Original-Received: from ip-90-186-1-98.web.vodafone.de ([90.186.1.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Jan 2016 06:17:51 +0100 Original-Received: from michael_heerdegen by ip-90-186-1-98.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Jan 2016 06:17:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-1-98.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:JbYAuyvKQAYE1k9PoK7A5cZaAYg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:197417 Archived-At: Drew Adams writes: > > pcase is not only useful when destructuring is involved (though > > it is the most important feature). > > I disagree. I think it is only useful when destructuring is > involved. If it is just doing literal pattern-matching then > it offers nothing more than does `cl-case'. Well, there are some more pattern types available, and you can all combine them. > (Unless it lets you change the equality predicate (does it?). No, but you can just use (pred (my-eq thing)) as pattern. That would test whether `thing' is `my-eq' to the object. > > The often cited case of a long list of conditions that only tests > > for equality for a longer list of symbols is a good example, > > I don't know what example you mean. Do you mean testing > for equality against more than one symbol, as in multiple > `cl-case's? Or testing the same symbol value more than once > (just use a `let')? I was talking about Lars' example. > The same would be true of a let construct that only destructures > (e.g., `destructuring-bind'). destructuring-bind is much less powerful than pcase. pcase can test whether something matches, combined with condition testing, boolean operations and local variable binding. There are cases where it's worth it to prefer pcase over other tools where no destr-bind is involved. But that's a minority of cases, yes. Michael.