From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: The poor state of documentation of pcase like things. Date: Sat, 2 Jan 2016 19:46:32 -0800 (PST) Message-ID: <92231dbf-1b5f-43ef-8792-fa44d5c4073e@default> 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1451792819 25368 80.91.229.3 (3 Jan 2016 03:46:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 03:46:59 +0000 (UTC) To: Michael Heerdegen , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 03 04:46:47 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 1aFZcx-0002gE-LT for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 04:46:43 +0100 Original-Received: from localhost ([::1]:40402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcx-0002Qu-0d for ged-emacs-devel@m.gmane.org; Sat, 02 Jan 2016 22:46:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcs-0002Pc-KV for emacs-devel@gnu.org; Sat, 02 Jan 2016 22:46:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFZcp-0000yk-EA for emacs-devel@gnu.org; Sat, 02 Jan 2016 22:46:38 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:26873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcp-0000yC-7Q for emacs-devel@gnu.org; Sat, 02 Jan 2016 22:46:35 -0500 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u033kY42010286 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 03:46:34 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u033kYFU021148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 03:46:34 GMT Original-Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u033kXCH025532; Sun, 3 Jan 2016 03:46:34 GMT In-Reply-To: <87y4c7xs8l.fsf@web.de> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 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:197409 Archived-At: > You can write good and bad > pcase code, code that emphasizes what it's doing, and code that looks > more like the result of a mechanical replacement. +1 for that formulation: "code that emphasizes what it's doing". When I see a `pcase' I want it to be telling me that there is some local-binding (decomposition pattern-matching) going on. > But I think I agree to the goal to use cl-case where possible. > cond is a bit different, Definitely different from `cl-case', since it does not do any pattern-matching (except perhaps by explicit testing with a predicate). > since it is as powerful as pcase (in principle), See previous - it does not do pattern-matching. And that is the particular "power" of `pcase' - what it really has to offer (IMO). > so when you see a cond, you can't assume much about what is (not) done > there. > 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'. (Unless it lets you change the equality predicate (does it?). That's one thing that I wish `cl-case' (and Common lisp `case') would let you do: specify something a comparer other than `eql'.) > 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')? > but also an extreme one, because this is a case that doesn't appear > so often in practise. >=20 > Oh, and I also think there are a lot of places in the sources that would > get simpler when using pcase. To vague to judge whether you are right. But maybe so, if you mean taking advantage of destructuring. The same would be true of a let construct that only destructures (e.g., `destructuring-bind').