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: Fri, 1 Jan 2016 19:51:39 -0800 (PST) Message-ID: <60ef02d8-49e9-4b1b-8c82-80c2ddcb90c6@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> 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 1451706725 13098 80.91.229.3 (2 Jan 2016 03:52:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Jan 2016 03:52:05 +0000 (UTC) Cc: Michael Heerdegen , emacs-devel@gnu.org To: John Wiegley , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 02 04:51: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 1aFDEO-0005rZ-Fv for ged-emacs-devel@m.gmane.org; Sat, 02 Jan 2016 04:51:52 +0100 Original-Received: from localhost ([::1]:37407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFDEN-0005JP-Sz for ged-emacs-devel@m.gmane.org; Fri, 01 Jan 2016 22:51:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFDEK-0005JD-4L for emacs-devel@gnu.org; Fri, 01 Jan 2016 22:51:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFDEJ-0003uc-7a for emacs-devel@gnu.org; Fri, 01 Jan 2016 22:51:48 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:16585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFDEF-0003uH-G5; Fri, 01 Jan 2016 22:51:43 -0500 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u023pfhh019488 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 2 Jan 2016 03:51:42 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u023pfTw004540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 2 Jan 2016 03:51:41 GMT Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u023peF7029336; Sat, 2 Jan 2016 03:51:41 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: aserv0021.oracle.com [141.146.126.233] 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:197333 Archived-At: > > (pcase skip > > (`nil nil) > > (`0 t) > > (_ (setq i (+ i skip -1)) (funcall get-next-frame))) >=20 > (cond ((null skip)) > ((eq skip 0) t) > (t (setq i (+ i skip -1)) > (funcall get-next-frame))) Agreed. If you don't need decomposition by pattern matching, why would you need `pcase'? (But as pointed out, the first clause should be ((null skip) nil). (The `cond' is 10 chars more to type in this case, not counting insignificant whitespace. But that is not important.) Or: (cl-case skip ((nil) nil) (0 t) (t (setq i (+ i skip -1)) (funcall get-next-frame))) (Same number of chars as `pcase'. Or 3 fewer, if you use alias\ `case'. But, again, not important.) Or: (and skip (or (eql 0 skip) (progn (setq i (+ i skip -1)) (funcall get-next-frame)))) (3 chars more than the `pcase'. But not important.) > Not much difference. Also, `0 could just be 0. >=20 > One thing it does do: avoids repeating "skip" in the first two tests. Tha= t's > the only merit I can see, but would have been more worthwhile if there we= re, > say, 10 value tests. The same is true of `cl-case' (it is one of the reasons for that macro). But otherwise, just use `let': (let ((sk skip)) (and sk (or (eql 0 sk) (progn (setq i (+ i skip -1)) (funcall get-next-frame))))