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 [Was: Re: Replace trivial pcase occurrences in the Emacs sources] Date: Mon, 29 Oct 2018 00:09:36 +0100 Message-ID: <87tvl5653j.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <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> <87a7mze7tl.fsf@web.de> <87zhuykjjh.fsf@web.de> <871s8aesdc.fsf@portable.galex-713.eu> <87tvl6dc3e.fsf_-_@portable.galex-713.eu> <87efc9isxj.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 1540768129 30247 195.159.176.226 (28 Oct 2018 23:08:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2018 23:08:49 +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 Mon Oct 29 00:08:44 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 1gGuAl-0007lf-Tt for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 00:08:44 +0100 Original-Received: from localhost ([::1]:42525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGuCr-0003nc-Uh for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2018 19:10:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGuC9-0003jx-4K for emacs-devel@gnu.org; Sun, 28 Oct 2018 19:10:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGuC7-0006xa-UE for emacs-devel@gnu.org; Sun, 28 Oct 2018 19:10:09 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:56088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gGuC5-0006mX-1S; Sun, 28 Oct 2018 19:10:07 -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 1gGuBc-0008De-BH; Mon, 29 Oct 2018 00:09:36 +0100 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: <87efc9isxj.fsf@web.de> (Michael Heerdegen's message of "Sun, 28 Oct 2018 23:54:00 +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:230759 Archived-At: Le 28/10/2018 =C3=A0 23h54, Michael Heerdegen a =C3=A9crit=C2=A0: > "Garreau, Alexandre" writes: >> Maybe that would make more sense if ` (and '?) were not part of pcase=E2= =80=99s >> own mini-language, redefined by pcase, but if pcase actually truly >> eval=E2=80=99d its pattern, defining pred, guard, etc. as real functions, >> defined with a cl-letf, using lexical scoping so to prevailably define >> all these + user-defined patterns. > > I think it would also be an interesting approach. You would > additionally need some magical thing that binds variables for the scope > of the current clause, however. That doesn't fit into that simple > approach. But not less than into pcase itself. =E2=80=9C(var name)=E2=80=9D, as does racket and some common-lisp match/uni= fy implementations. And so to integrate with =E2=80=9C`=E2=80=9D: =E2=80=9C,(= var name)=E2=80=9D doesn=E2=80=99t disturb me, it is okay: will bind =E2=80=9Cname=E2=80=9D to something, pret= ty straightforward. > I wonder if it could be similarly efficient as pcase. I=E2=80=99m almost sure it wouldn=E2=80=99t, or otherwise it would be awful= ly complex. But, if there were something to replace ` while not being counter-intuitive, I could live with ` not being efficient, but intuitive. >> It even more feel wrong that, this, doesn=E2=80=99t work, for no reason > > Well, there is a reason: it is wrong ;-) > >> #+BEGIN_SRC emacs-lisp >> (pcase [1 2] >> ([a b] (+ a b))) >> #+END_SRC > > That should be=20 > > #+begin_src emacs-lisp > (pcase [1 2] > (`[,a ,b] (+ a b))) > #+end_src > > I'm sure you would have been able to find that after less than a minute > when reading the pcase docstring. I found that before sending the mail. But what I said I feel wrong, is that this is wrong, after current pcase rules. While it works for guile and racket match, as well as several common lisp match, with only some common-lisp match such as cl-match and optima as exceptions. What is confusing is [] can=E2=80=99t serve for the pattern language, so it feels wrong to disallow using it for pattern matching. Beside lisp, all pattern matching language make their feature serve one purpose: the pattern look like what the data should be. adding =E2=80=9C`=E2=80=9D and = =E2=80=9C,=E2=80=9D destroy this feature, because the pattern no longer looks like what is matched.