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 00:00:24 +0100 Message-ID: <87va5kqrxz.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <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> <87tvl5653j.fsf@portable.galex-713.eu> <87zhuxhbeo.fsf@web.de> <87lg6hxda6.fsf@portable.galex-713.eu> <87va5kigkp.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 1540853928 23443 195.159.176.226 (29 Oct 2018 22:58:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 22:58:48 +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 23:58: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 1gHGUd-0005yo-Me for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 23:58:43 +0100 Original-Received: from localhost ([::1]:49458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHGWk-0008Tj-1m for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 19:00:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHGWY-0008TT-E1 for emacs-devel@gnu.org; Mon, 29 Oct 2018 19:00:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHGWX-0005Sb-A2 for emacs-devel@gnu.org; Mon, 29 Oct 2018 19:00:42 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:59540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHGWV-0005Qc-5Z; Mon, 29 Oct 2018 19:00:41 -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 1gHGWG-0007lw-Ce; Tue, 30 Oct 2018 00:00:24 +0100 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: <87va5kigkp.fsf@web.de> (Michael Heerdegen's message of "Mon, 29 Oct 2018 22:33:10 +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:230782 Archived-At: Le 29/10/2018 =C3=A0 22h33, Michael Heerdegen a =C3=A9crit=C2=A0: > "Garreau, Alexandre" writes: > >> Even in pcase I don=E2=80=99t see how to do that except manually using (= and var >> (guard (equal var val))), > > You mean like (pred (equal val))? Oh indeed! Still that defeat the purpose of pattern matching by requiring non-pattern matching stuff. >> #+begin_src emacs-lisp >> (pcase-defmacro list (&rest args) >> `(,'\` ,(mapcar (lambda (thing) `(,'\, ,thing)) args))) >> #+end_src >> >> I tried to adapt for arrays: >> >> #+begin_src emacs-lisp >> (pcase-defmacro array (&rest args) >> `[,'\` ,(mapcar (lambda (thing) `(,'\, ,thing)) args)]) >> #+end_src > >> But it doesn=E2=80=99t work x), that, plus my initial non-working >> =E2=80=9C(pcase-defmacro list (&rest args) ``(,@args))=E2=80=9D, I must = find =E2=80=9C`=E2=80=9D, is, >> indeed, quite confusing (how is =E2=80=9C,'=E2=80=9D needed? how isn=E2= =80=99t =E2=80=9C,'\`=E2=80=9D equivalent >> to =E2=80=9C\`=E2=80=9D?), > > You want , to survive til after the macro expansion. Backquote can't > know that it should ignore a , because you want it to be literally in > the expansion. ,'\` let's backquote insert a literal , into the > expansion, which is what you want. The underlying problem is that you > want to use (of course you don't have to!) backquote to construct a > backquote expression. That happens here and there when writing Lisp, > it's not something special to pcase. Yes I know, what I meant is `, in lisp, can generally lead to confusion unexperimented programmer. That=E2=80=99s one of the selling points of hyg= ienic macros (standard and default in scheme). The fact pcase is not strictly treating ` as standard lisp=E2=80=99s reader= does is only *adding* the the already existing confusion normal and standard ` introduces in lisp. > 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 explain= to me how does exactely work the =E2=80=9C,=E2=80=9D macro, as it stays context depen= dant, 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). > Your pcase macro `array' could be defined like > > #+begin_src emacs-lisp > (pcase-defmacro array (&rest args) > `(,'\` [,@(mapcar (lambda (thing) `(,'\, ,thing)) args)])) > #+end_src > > You could also write that without backquote (and also without the [] > reader syntax). Ah okkkk! Backquotes may be difficult or confusing to master fully, but at least they=E2=80=99re consistent and simple enough to stay readable, I f= ind, more easily than easily writable.