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: pcase ` meaning Date: Tue, 30 Oct 2018 01:17:51 +0100 Message-ID: <87in1kqocw.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <87h9iunkcg.fsf@web.de> <87h8hc4xw2.fsf_-_@web.de> <83tvlcsnee.fsf@gnu.org> <87pnw037ar.fsf@web.de> <83ftwvs7y9.fsf@gnu.org> <877ei7mkfh.fsf@web.de> <87a7mze7tl.fsf@web.de> <87zhuykjjh.fsf@web.de> <871s8aesdc.fsf@portable.galex-713.eu> <87tvl6dc3e.fsf_-_@portable.galex-713.eu> <87efc9isxj.fsf@web.de> <87tvl5653j.fsf@portable.galex-713.eu> <87zhuxhbeo.fsf@web.de> <87lg6hxda6.fsf@portable.galex-713.eu> <87va5kigkp.fsf@web.de> <87va5kqrxz.fsf@portable.galex-713.eu> <87zhuwwbkc.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 1540858567 4351 195.159.176.226 (30 Oct 2018 00:16:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 00:16:07 +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 , Dmitry Gutov , Stefan Monnier , emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 01:16:03 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 1gHHhS-00011u-AJ for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 01:16:02 +0100 Original-Received: from localhost ([::1]:49794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHjY-0005C1-M3 for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 20:18:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHjP-00050y-EE for emacs-devel@gnu.org; Mon, 29 Oct 2018 20:18:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHHjO-0006S1-EW for emacs-devel@gnu.org; Mon, 29 Oct 2018 20:18:03 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:59598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHHjO-0006Md-57; Mon, 29 Oct 2018 20:18:02 -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 1gHHjE-0008Op-1U; Tue, 30 Oct 2018 01:17:52 +0100 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: <87zhuwwbkc.fsf@web.de> (Michael Heerdegen's message of "Tue, 30 Oct 2018 00:57:39 +0100") 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:230787 Archived-At: On 2018/10/30 at 00:57, Michael Heerdegen wrote: > "Garreau, Alexandre" writes: > >> > You mean like (pred (equal val))? >> >> Oh indeed! Still that defeat the purpose of pattern matching by >> requiring non-pattern matching stuff. > > What in that pattern is non-pattern matching stuff? guards, pred, etc. are =E2=80=9Cpattern=E2=80=9D in pcase parlance, but are= n=E2=80=99t pattern-matching in general sense: they are only a (handy) extra way to specify arbitrary conditions in the middle of a pattern matching, in addition to matching the *pattern*, that is a structure that mimick what we want to match. >> The fact pcase is not strictly treating ` as standard lisp=E2=80=99s rea= der does >> is only *adding* the the already existing confusion normal and standard >> ` introduces in lisp. > > ` is a normal macro, it has nothing to do with the reader. Apart from > the ` reader macro, which pcase doesn't touch at all. They share a name, that=E2=80=99s enough. And to me it seems that this name sharing is here to (incompletely / incorrectly) borrow some of the semantics of the ` reader macro. > What it does is to give ` different semantics inside patterns. Like > your `list' pattern gives new semantics to the symbol `list'. Oh my. It=E2=80=99s not arbitrary random semantics, it base on the knowledge people might have of =E2=80=9C`=E2=80=9D, and of its use along with =E2=80=9C,=E2= =80=9D. List, at the opposite, is pure pattern matching, since it is used as a list constructor, look: (pcase (list 1 2 3) ((list 1 2 3) t)) It just looks *exactely* the same. (pcase (list 1 2 3) ((list a b c) (+ a b c))) And here it=E2=80=99s *almost* the same, beside identifiers, to be bound. While: (pcase `(1 2 3) (`(1 2 3) t)) look the same, as well as: (pcase `(a b c) (`(a b c) t)) But not: (pcase `(1 2 3) (`(,a ,b ,c) (+ a b c))) >> > For understanding the definition above note that ``' (synonymous for >> > `backquote') is a (very normal) macro accepting one argument STRUCTURE, >> > whereby we also have an abbreviating reader syntax >> > `STRUCTURE =3D=3D (` STRUCTURE). We also have the reader syntax >> > ,THING =3D=3D (, THING). >> >> Indeed you=E2=80=99re right, but that doesn=E2=80=99t automagically expl= ain to me how >> does exactely work the =E2=80=9C,=E2=80=9D macro, as it stays context de= pendant, not >> trivial, and to me, =E2=80=9C,=E2=80=9D meant either =E2=80=9Ceval=E2=80= =9D or =E2=80=9Cundo =E2=80=98`=E2=80=99=E2=80=9D (the later is >> nearer to the meaning used in pcase btw). > > (, is not a macro, btw) Well, in pcase patterns it "means" something > different. As `and' means something different in `rx'. Yes. A different meaning for `and', is acceptable, and the first time I saw a complain about it I also immediatly thought to `rx'. But if `and' meaning change is acceptable it=E2=80=99s because =E2=80=9Cand=E2=80=9D is = already a word of english with an abstract, independant, general meaning per se. While =E2=80=9C`=E2=80=9D is almost never used as in lisp, except as *real* quote= s, that match, as in `' in TeX (or docstrings), or `` in shellscript. > You very often say that you expected something different. I dunno what > I first expected, I read the docs to learn pcase, and it took 5 minutes. I sometimes exagerate in reguard to pcase understandability: I find its syntax confusive because it is actually inconsistent with outside-pcase-world, and I=E2=80=99m a perfectionist (that=E2=80=99s a defe= ct that can be workaround, still). I do that because, though I=E2=80=99m not fond of pattern matching, I do th= ink sometimes it=E2=80=99s handy, useful or even necessary, and then I=E2=80=99= d like pcase to be the most easily understandable by the most possible people. > I think we can agree that we disagree - I just don't share your > opinion. The thing is designed in a way that it matches how some, but > not all people, like to think about pattern matching. Not that much I believe: you were enthusiast as well about the `var' pattern, and I=E2=80=99m pretty sure (and guess I=E2=80=99m not the only on= e) than borrowing some patterns from other lisps pattern matching facilities may allow less confusing pcase usages, as you initially wanted. The one I=E2=80=99d push the harder, and find the most important, is (a b c) (not quoted) to match a list, when no `a' pattern is defined, as it is done in schemes=E2=80=99 match, and the most naive and simple common-lisp m= atch. Here I know pcase, currently, refuse it, but I didn=E2=80=99t yet hear peop= le talk against it, but I may expect to be a minority to want this, or at least not to be a majority wanting it, or to have some people (Stefan?) against it.