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:45:53 -0800 (PST) Message-ID: <0f243fb0-71c9-43e9-82a8-83dfc9bec48e@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> <56886E32.70305@yandex.ru> <99364c8d-ba83-4e10-8345-5bd8dc926e7d@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1451792792 25185 80.91.229.3 (3 Jan 2016 03:46:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 03:46:32 +0000 (UTC) Cc: dak@gnu.org, michael_heerdegen@web.de, emacs-devel@gnu.org, Dmitry Gutov , Lars Magne Ingebrigtsen , Daniel Colascione , Eli Zaretskii To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 03 04:46:19 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 1aFZcY-0002Eq-PT for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 04:46:18 +0100 Original-Received: from localhost ([::1]:40400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcY-0001zD-5R for ged-emacs-devel@m.gmane.org; Sat, 02 Jan 2016 22:46:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcU-0001uz-1H for emacs-devel@gnu.org; Sat, 02 Jan 2016 22:46:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFZcS-0000SE-V0 for emacs-devel@gnu.org; Sat, 02 Jan 2016 22:46:13 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:42171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFZcO-0000QE-SG; Sat, 02 Jan 2016 22:46:08 -0500 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u033jvh5016942 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 03:45:59 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u033jsRL024432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 03:45:56 GMT Original-Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u033jsXr026535; Sun, 3 Jan 2016 03:45:54 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:197408 Archived-At: > >> Well, I'd say that pcase is kinda awkward because you can't tell by > >> skimming whether it's complex or not > > > > 100% agreement. That's really the point, for me. > > > > * `pcase' shouts: "This might be complicated. Better look closely." > > > > * `cond' and `cl-case' and `if' ... shout: "Nothing fancy here. > > We're only testing literals" >=20 > I don't see how `cond' and `if' shout that at all, they can test > anything, no restrictions. I would prefer `pcase` over `cond` (if > there were some reason to exclude `cl-case') because the code is > shorter and simpler so I can skim it faster than the equivalent > `cond'. I tried to consistently contrast what they do with the "_decomposition pattern-matching_" that `pcase' can do (in addition to only matching literal "patterns" - `eql'). Sorry if that wasn't clear. Of course the ordinary control structures can perform any kind of test. That's not in question. But when it comes to _pattern matching_ (e.g., for `cl-case'), only literal matches are done. `pcase' is unique among control structures in being able to decompose what a pattern matches, i.e., to bind local variables. This is really what it has to offer (IMHO). The rest is nothing new. And I would (personally) typically use it only when it was doing that. You could get `pcase' behavior with just a decomposing let combined with the classic control structures. You might even argue that that might be clearer. (I used to use a Lisp, many moon ago, that had such a let, but I've forgotten what it was. Maybe it was something I wrote, instead of being part of the language - I don't recall.)