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: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]] Date: Sun, 28 Oct 2018 18:57:25 +0100 Message-ID: <87lg6i7y4a.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <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> <87d0rud6gt.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 1540749551 15793 195.159.176.226 (28 Oct 2018 17:59:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2018 17:59:11 +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: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 28 18:59:07 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 1gGpL7-0003y0-05 for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2018 18:59:05 +0100 Original-Received: from localhost ([::1]:41355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGpND-0004nb-Av for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2018 14:01:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGpM0-0004ld-EL for emacs-devel@gnu.org; Sun, 28 Oct 2018 14:00:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGpLl-0001UZ-Ae for emacs-devel@gnu.org; Sun, 28 Oct 2018 13:59:51 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:55874) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gGpJz-0000b5-O5 for emacs-devel@gnu.org; Sun, 28 Oct 2018 13:59:33 -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 1gGpJV-0007WP-Kz; Sun, 28 Oct 2018 18:57:25 +0100 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: (Stefan Monnier's message of "Sun, 28 Oct 2018 09:44:11 -0400") 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:230754 Archived-At: On 2018-10-28 at 09:44, Stefan Monnier wrote: >> Okay, so I went to search what is done in other pattern matching lisp >> form. > > You missed Racket's `match` (https://docs.racket-lang.org/reference/match= .html) Indeed! Thank you! I missed it because when reading guile reference (incidentelly already installed on my system, while I don=E2=80=99t even kn= ow if racket=E2=80=99s is installable as info, pdf, man or even html here), I nai= vely thought if it said most schemes used the same, racket would too. And indeed, it seems pretty compatible, beside being interestingly way richer, having the `list', `vector', etc. patterns I found in cl-match=E2= =80=A6 and I=E2=80=99m very happy the `var' I made out of =E2=80=9CLisp, 3rd ed=E2= =80=9D book annex I found happen to be just the same, compatible with racket: this easily paliates for binding all constructs which aren=E2=80=99t bindable in guile= =E2=80=99s match (=E2=80=9C((var list) foo)=E2=80=9D to bind the symbol =E2=80=9Clist= =E2=80=9D as a first element). > Incidentally, I also missed it when I did the same search you did before > embarking on the design and implementation of pcase. I later found > Racket's `match` which was pretty close to the original design of pcase, > but showed me how to add `pcase-defmacro` (mostly by adding the `app` > pattern), which led to the "new pcase" where ` is a macro (and where > ' was added for that macro to have something to expand to). What was is initially? non-existing? > The current `pcase` is pretty close to Racket's `match`. The main > missing functionality is the negation, In terms of powerfulness, however, to come back to original discussion: confusion. The presence of type constructors (`list', `array'), the fact lists and arrays, otherwise (if not matching a defined pattern) work out of the box, and the `var' form, allow, if needed, to completely avoid the =E2=80=9C`=E2=80=9D syntax. And to me it=E2=80=99s like it appea= r that this syntax is confusing quite some people (and I understand why, except when in ,(foo) `foo' is a defined pattern, so it=E2=80=99s look like a function call). So avoiding this syntax in source code could be handy so to give a better image to pcase, which would understood more easily. > which Racket solves "easily" because its underlying language handles > lambda much more efficiently (i.e. the code generated by `match` would > work very poorly in Elisp unless we significantly improved the > byte-compiler's handling of funcall). >From what I feel sometimes scheme=E2=80=99s byte-compiler are pretty handy, maybe less than some cl compilers, but=E2=80=A6 well maybe it is only that = elisp byte-compiler doesn=E2=80=99t do that much, does it?