From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier 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 09:44:11 -0400 Message-ID: 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> <87d0rud6gt.fsf_-_@portable.galex-713.eu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540734187 13538 195.159.176.226 (28 Oct 2018 13:43:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2018 13:43:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 28 14:43: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 1gGlLK-0003R4-Tu for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2018 14:43:03 +0100 Original-Received: from localhost ([::1]:40190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGlNR-0005w9-6u for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2018 09:45:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGlMi-0005w3-NJ for emacs-devel@gnu.org; Sun, 28 Oct 2018 09:44:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGlMf-0007SU-Ic for emacs-devel@gnu.org; Sun, 28 Oct 2018 09:44:28 -0400 Original-Received: from [195.159.176.226] (port=59777 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gGlMe-0007Qb-BA for emacs-devel@gnu.org; Sun, 28 Oct 2018 09:44:25 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gGlKQ-0002Tf-MS for emacs-devel@gnu.org; Sun, 28 Oct 2018 14:42:06 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 21 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:kozpcdpJFziT3JXsgCC2/w8XKJ8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 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:230751 Archived-At: > 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) 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). The current `pcase` is pretty close to Racket's `match`. The main missing functionality is the negation, 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). Stefan