From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Garreau\, Alexandre" Newsgroups: gmane.emacs.devel Subject: Re: Replace trivial pcase occurrences in the Emacs sources Date: Wed, 24 Oct 2018 20:47:39 +0200 Message-ID: <87a7n39o6s.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <56892334.4000106@yandex.ru> <8760zakb7q.fsf@fencepost.gnu.org> <56892BDA.6060103@dancol.org> <871t9yk98g.fsf@fencepost.gnu.org> <568936F0.3060505@yandex.ru> <87wprqitj5.fsf@fencepost.gnu.org> <56893C8C.3060200@yandex.ru> <87oad2irtd.fsf@fencepost.gnu.org> <5689456A.1010601@yandex.ru> <87egdy8tyz.fsf@fencepost.gnu.org> <56895FDE.4060406@yandex.ru> <8760za8r4a.fsf@fencepost.gnu.org> <87h9iunkcg.fsf@web.de> <87h8hc4xw2.fsf_-_@web.de> <83tvlcsnee.fsf@gnu.org> <87pnw037ar.fsf@web.de> <83ftwvs7y9.fsf@gnu.org> <877ei7mkfh.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1540406814 9155 195.159.176.226 (24 Oct 2018 18:46:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 24 Oct 2018 18:46:54 +0000 (UTC) User-Agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian Cc: Eli Zaretskii , Stefan Monnier , emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 24 20:46:50 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFOB7-0002Gg-Kd for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2018 20:46:49 +0200 Original-Received: from localhost ([::1]:49860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFODE-0000s7-6c for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2018 14:49:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFOC2-0008OZ-7t for emacs-devel@gnu.org; Wed, 24 Oct 2018 14:47:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFOC1-00040C-85 for emacs-devel@gnu.org; Wed, 24 Oct 2018 14:47:46 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:45960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFOC0-0003zS-W1; Wed, 24 Oct 2018 14:47:45 -0400 Original-Received: from localhost ([::1] helo=portable.galex-713.eu) by portable.galex-713.eu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFOBv-0007Nt-F9; Wed, 24 Oct 2018 20:47:39 +0200 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: <877ei7mkfh.fsf@web.de> (Michael Heerdegen's message of "Wed, 24 Oct 2018 17:30:26 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:5884:8305::1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:230642 Archived-At: On 2018-10-24 at 17:30, Michael Heerdegen wrote: > Eli Zaretskii writes: > >> FWIW, my main problem is not even with cl-case, it's with 'cond'. It >> seems like we have some 'pcase' epidemic, whose first symptom is that >> people stop using 'cond' and start using 'pcase' instead. A few >> examples: >> >> todo-mode.el: >> >> (pcase this-param >> ('edit (todo-edit-item--text)) >> ('header (todo-edit-item--text 'include-header)) >> ('multiline (todo-edit-item--text 'multiline)) >> ('add/edit (todo-edit-item--text 'comment-edit)) >> ('delete (todo-edit-item--text 'comment-delete)) >> ('diary (todo-edit-item--diary-inclusion)) >> ('nonmarking (todo-edit-item--diary-inclusion 'nonmarking)) >> [...] >> >> auth-source-pass.el: >> >> (pcase (length matching-entries) >> (0 (auth-source-pass--do-debug "no match found") >> nil) >> (1 (auth-source-pass--do-debug "found 1 match: %s" (car matching-e= ntries)) >> (car matching-entries)) >> (_ (auth-source-pass--select-one-entry matching-entries user))))) >> >> bs.el: >> >> (setq bs-buffer-show-mark (pcase bs-buffer-show-mark >> (`nil 'never) >> (`never 'always) >> (_ nil)))))) >> >> calculator.el: >> >> (<=3D inp (pcase calculator-input-radix >> (`nil ?9) (`bin ?1) (`oct ?7) (_ 999)))) >> >> lpr.el: >> >> (pcase (count-lines (point-min) (point-max)) >> (0 "") >> (1 ": ") >> (_ ":\n")) > > FWIW, these are the major cases I wanted to treat, but I wanted to > replace them with equivalent cl-case forms, not with `cond's. > >> (Quick: what's the difference between `require and 'require in this >> case?) > > There is none any more. > >> easy-mmode.el: >> >> (pcase keyw >> (`:group (setq group (nconc group (list :group (pop keys))))) >> (`:global (setq keys (cdr keys))) >> (_ (push keyw extra-keywords) (push (pop keys) extra-keywords)))) >> >> (Aren't keywords supposed to be self-quoting? then why they are >> explicitly quoted?) > > Yes. > >> We have dozens of such fragments in our codebase, which just makes the >> sources harder to read, especially for people who aren't fluent with >> 'pcase' (which seems to be the case with many of us). > > These are all cases I would want to fix, but unless the whole pcase form > can be trivially rewritten as cl-case, I want to leave pcase, really. I=E2=80=99d prefer much this, as I find `case' well much less redundant, it= =E2=80=99s just basic factorization. Programming is here to factorize, so it should be factorized. Even C do that. Case is the simpler, most obvious and straightforward to factorize a lot of cond (it is a shame we don=E2=80=99t have it with equal, some case* or case-equal would be appreciated).