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: Replace trivial pcase occurrences in the Emacs sources Date: Wed, 31 Oct 2018 20:50:58 +0100 Message-ID: <871s85yjx9.fsf@web.de> References: <83tvlcsnee.fsf@gnu.org> <20181029130132.GB4195@ACM> <20181029134722.GC4195@ACM> <87lg6gifnb.fsf@web.de> <87muqwxs7m.fsf@ericabrahamsen.net> <83h8h3jlyd.fsf@gnu.org> <8b897e43-679b-d38c-e185-0efe19c09342@yandex.ru> <83y3aei08p.fsf@gnu.org> <83o9bahz6i.fsf@gnu.org> <877ehyx7xg.fsf@web.de> <83d0rpj4y0.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1541015358 24291 195.159.176.226 (31 Oct 2018 19:49:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Oct 2018 19:49:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, monnier@IRO.UMontreal.CA, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 31 20:49: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 1gHwUM-0006E1-7J for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 20:49:14 +0100 Original-Received: from localhost ([::1]:33240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHwWS-0001RS-Jd for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 15:51:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHwWH-0001Pk-CS for emacs-devel@gnu.org; Wed, 31 Oct 2018 15:51:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHwWC-00073m-Dv for emacs-devel@gnu.org; Wed, 31 Oct 2018 15:51:13 -0400 Original-Received: from mout.web.de ([212.227.15.14]:36817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHwWC-000734-4a; Wed, 31 Oct 2018 15:51:08 -0400 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MKrOS-1gHwW40hou-0003Uj; Wed, 31 Oct 2018 20:51:00 +0100 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MKrOS-1gHwW40hou-0003Uj; Wed, 31 Oct 2018 20:51:00 +0100 In-Reply-To: <83d0rpj4y0.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 31 Oct 2018 21:23:35 +0200") X-Provags-ID: V03:K1:uPRerweZs+RKXoUnJtkm9ZmnHukabK2aAfrF6Q6B7h+U1e3xPRg 9ScDNASdreYNJcwOlrKjb/zYhvFuWC0pJl5F2MoN0/Yuz1Czx+giQ3HH+UUNkxm+vh0Y+EF cimiUb4w34Rdxp400Ni6c9TbNaDAoVSTt9mjRMg46xklTRldZDX++5I0xwp8+Txnht+qdZ4 B+n2UvwunQWaqxk/Rc/NA== X-UI-Out-Filterresults: notjunk:1;V01:K0:s65KX1+BC6s=:O7JxUnGcgmQVTl9ELD9uPn IHV0rha+OVOF443EwQoFGTZ7ahXEmTbj5w2g+XCjdSXVAwXayu8NBrGfpN1fnhdl+VL6cboul r1wthfSw71x3B9cXqiFBjx5eyDn5JxPU9tGP6DVZ9H4LGcmSBXcNKliM9dHY+cjY5Dek/v3OC gskoKEPoeXMPQ38wKve7o1CUIdPBfkt5IMdd8MSx3JBI9r4pWw0Sbm9JFwUgmN1oexi8qWFWi pI6MSnCVnBK4NpfoB9wzErO2C3ObYUEQzuDZfivx/gupvvBJ2C8J30chJyxwPXN8wgPACk/6h vfsszKzQGKrQaJ5QoZVAbjQcIe/OMORjsrvcEJ3fuCQoIY+WGv43Bv74/40Pkdk50offxq9iJ MPyw8qXEPgo0ubuWZrQ9ouXRRmRlKUh5VKo66bGl9wyBzIyohLSsfaEsJiOOeVRIVvHq1ZMaa ngnkO2FHI9b67DHasAKvYJYvMrgq1YdjvcLONEcVJ4SRMAbG/A2/P6IL2ZSBqzRNntjuzpvK2 TKoUhCtI3e9LLyU7LxDLrlj3rDAvBh6wFWw55TvT0QJVg0P61hH/qb2H1H/a537tehxLuS+/V Dpnh4EJw+D/GSdi7IFekGvAptk2u6OGc+VDEEo/rpwGVMLGogM13VxyV/+EhkyU1mhvKFmQya F969le+TQhgZhj1zCaOx6aZPJcOm/fsvZp2Kw0DXv63+VxbfK7tJIpSv192h2wF4QtqdMGBhU OtUutUq5/dF28Np3VMATD3aalInKLMxlwrDi7wCFifqGFytKOPpq3pSdi0YGX9uTKPEj0p6G X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.14 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:230909 Archived-At: Eli Zaretskii writes: > > I wouldn't call a `let' or `app' pattern that introduces a new binding > > destructuring per se. OTOH, I would call a pattern using ` that tests > > e.g. the car of the matched object with e.g. `pred' destructuring even > > if that car is not bound to a variable. > > Can you give an example? I don't think I follow. (pcase '(1 2 3) ((let a 3) a)) ==> 3 Is the used pattern destructuring? It binds a variable. Or (pcase '(1 2 3) ((app (lambda (thing) 27) x) x)) ==> 27 As in the above example, the pattern ignores the given object. OTOH, when you use `app' with a function like `car' (the ` pcase macro is defined like this), it can be used for destructuring. The feature to bind variables is totally orthogonal to destructuring. The two are often used together, however, but that shouldn't let us confuse these two different things. > > With other words: I would say a pattern where subpatterns are matched > > against parts of a compound object is desctructuring. > > But note that your generalization is inconsistent with your example: > there's no "pattern matching" in the example, there's only a "matched > object", which is a matching of an entirely different kind. I think it is. I mean a pattern like `(,a ,b) is destructuring, independently from the object being matched, because when used for matching it (tries to) extract parts of a compound object and tests these with subpatterns (a, b in this case). The pattern fails to match objects that are not compound or have the wrong structure. But trying to use the pattern for matching tries to extract and analyse the parts of any object. That's why I would call the pattern destructuring. To give an exact accurate definition is nearly impossible, however. For example, is (or 'foo `(,a ,b)) desctructuring? Is (pred some-fun) destructuring if SOME-FUN may look at the parts of its argument? How would you define that? I don't think "destructuring" is such a good term to use in the docs, apart from giving a hint what ` is about. Michael.