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 18:47:27 -0800 (PST) Message-ID: 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> 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 1451789286 8273 80.91.229.3 (3 Jan 2016 02:48:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 02:48:06 +0000 (UTC) Cc: Eli Zaretskii , Daniel Colascione , emacs-devel@gnu.org To: Michael Heerdegen , David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 03 03:47:53 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 1aFYi0-0002BH-LX for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 03:47:52 +0100 Original-Received: from localhost ([::1]:40323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFYhz-0007aJ-R7 for ged-emacs-devel@m.gmane.org; Sat, 02 Jan 2016 21:47:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFYhv-0007a2-Pd for emacs-devel@gnu.org; Sat, 02 Jan 2016 21:47:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFYhu-0006AE-Tx for emacs-devel@gnu.org; Sat, 02 Jan 2016 21:47:47 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:21894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFYhp-00069O-5c; Sat, 02 Jan 2016 21:47:41 -0500 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u032lTPp009616 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 02:47:30 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 u032lToE015843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jan 2016 02:47:29 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 u032lTxe013247; Sun, 3 Jan 2016 02:47:29 GMT In-Reply-To: <87si2fwm38.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: 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: 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:197399 Archived-At: > I don't see how a pcase used like a cl-case - as in the quoted example - > is any harder to read or understand. >=20 > And of course it has also advantages to use pcase in such cases. If you > want to change the code or try things and you suddenly want a feature > from pcase, you don't have to rewrite the whole thing. >=20 > It just...arguable what you prefer. Yes. So let me argue ;-) in favor of using `pcase' only, or mainly, when decomposition pattern-matching is used, and not just for literal tests. Your point is that `pcase' is more general, so if you want to later add a clause that does make use of decomposition pattern-matching then it's easy to do so. That is a good argument. It's not the argument that persuades me, however. I generally come down on the side of trying to have the most readable code, even at the cost of more maintenance work, in terms of typing. Why? Because I think that code readability is primary, and the biggest maintenance burden is not typing but understanding. Why do I think that a control structure that tests only literals is clearer for literal-testing than one that also uses decomposition patterns? Because the former necessarily shouts that there are ONLY literal tests here. `pcase' is harder to parse not just because some of us might not be as used to it, but also precisely because of its generality. You have to look closely, to see whether there might be some decomposition pattern-matching going on. (Occam's razor. Einstein's as-simple-as-possible-but-no-simpler.) Because `pcase' is so general that it can handle also fancy patterns, its syntax is more involved - overkill. Not overkill for the cases where it makes sense and takes advantage of pattern matching. But overkill for the mundane, literal-matching cases. I prefer to use the simpler `cl-case' or whatever when possible, because it says, loud-and-clear, to a reader: "Nothing fancy here." The reader is the one who counts, for me, not the writer. And I don't mind having to later rewrite the code if a feature change or bug fix makes it possible to really take advantage of what `pcase' has to offer. Yes, that's an added burden, but one that I, personally, don't mind. (I'm talking about me and my code. I can understand, if Emacs maintainers feel differently about the distributed Emacs code.) IOW, I echo the hammer=3D>nail reflection that David made. There is no need to think that `pcase' _needs_ to be used everywhere, just because it _can_ be used everywhere. (And I feel the same about `loop', FWIW.) Just one opinion, of course.