From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources] Date: Mon, 29 Oct 2018 22:33:10 +0100 Message-ID: <87va5kigkp.fsf@web.de> References: <20151216202605.GA3752@acm.fritz.box> <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> <87tvl5653j.fsf@portable.galex-713.eu> <87zhuxhbeo.fsf@web.de> <87lg6hxda6.fsf@portable.galex-713.eu> 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 1540848798 11860 195.159.176.226 (29 Oct 2018 21:33:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 21:33:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eli Zaretskii , Dmitry Gutov , Stefan Monnier , emacs-devel@gnu.org To: "Garreau\, Alexandre" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 29 22:33:14 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 1gHF9s-0002wF-PF for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 22:33:12 +0100 Original-Received: from localhost ([::1]:49111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHFBz-00057X-7S for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 17:35:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHFAR-00054K-J7 for emacs-devel@gnu.org; Mon, 29 Oct 2018 17:33:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHFAN-0007BI-I4 for emacs-devel@gnu.org; Mon, 29 Oct 2018 17:33:47 -0400 Original-Received: from mout.web.de ([217.72.192.78]:47275) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHFAM-0006vH-NT; Mon, 29 Oct 2018 17:33:43 -0400 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MSads-1g7ElQ3azc-00RXiN; Mon, 29 Oct 2018 22:33:13 +0100 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MSads-1g7ElQ3azc-00RXiN; Mon, 29 Oct 2018 22:33:13 +0100 In-Reply-To: <87lg6hxda6.fsf@portable.galex-713.eu> (Alexandre Garreau's message of "Mon, 29 Oct 2018 11:22:57 +0100") X-Provags-ID: V03:K1:ttI8tQNzhhYJXdQmO4Wf8HMQ+R4dLcSdIXFlijIeY8GMcsLxaCV CAJcxhT8sLDn7aafksCIC2tQRgMd/evDhg9/aXWmdO6C86JW5BE7L3sUPNzmEQ9oLyG/N44 Fv/y0oeNszaxDHWY3PuL7Mb4oh52PEm87/73hu3zrOE15wlbybmGmTG4N0ka1GsW2BwBHQO PdFjvnYNzpzUhcGchENrQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:+IlTC0GLvhU=:6YWjl+54RjoDUjNXHnR6q/ a2ey3O20SJtQjXQd53Pe/gWkC9NDGGK/ohovmaTGxzpTyYVP3xDOWAC2jBm3BeT1nGkHDyfTS E4aypwyk9yFIARS9WMYlWlvv003+lHOpv+GDDDlGu5QMHszCQSyh7aojHOp4Fyxsb/viMecI6 qr/do4S7auPXsra8HbfA0dj1dehJu5p2CNs6buyHJVRGuS05T2BpTaDF2mKQBoip1P3HzBOeR 516tKmOTKgJIFZtL09mOTRToklY02xibAUuWWfgVOnySYm8vsePATJhHNxkEYO646eBRFXJM5 YG9RPRtjKgUCRkVrjU7fkhEATUUTCeKZu1YJn97Sagada7uNa5sViexy7sZEpmsuTy2WwbPNU PkVsNeadztWiMY4YLfZh0EEiZQbxUbmaLg7TljnQXZR+bXm2WOGQWjjWpOP4SkWCh/Snlq/Y2 mQAd8AKzT07QeiwKlle3mAjXDLYVXTtW/zHjQLTkVUD4wrvoLpFvS/rI5464DGU4CeMnNdum9 NjGC2j17Ui/nifLr106atxn0pc2wX0sD8RLoHTuofpCcDjoG0St04BZ1L2bH6l53D2IImDLgx uFwJtFwaaWavUZUv/2RpomOlxGyjjWlRqOKIpBfYT49w1wSTFv4izlAX0LAl5LYsgBrUj8yrb i+CJI2EqZPPySZxljQHgVFOf4ZJ03+QnYC5bbX5AaSfRMr+i7i3xHokjAeelSb7HmE8gQNALd EOvGDc7Ui4MvEujvhsR4gS2cPHUqQ20Ozz9m8LWSjepJf1ZVOTGn45a8xKGEMezYwkh0nAmv X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.78 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:230773 Archived-At: "Garreau, Alexandre" writes: > Even in pcase I don=E2=80=99t see how to do that except manually using (a= nd var > (guard (equal var val))), You mean like (pred (equal val))? > #+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 f= ind =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. 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). 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). Michael.