From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Replace trivial pcase occurrences in the Emacs sources Date: Thu, 1 Nov 2018 10:36:33 +0000 Message-ID: <20181101103633.GB4504@ACM> References: <83k1lzjq0r.fsf@gnu.org> <83in1jjmy4.fsf@gnu.org> <20181031120821.GA20575@ACM> <831s86jey9.fsf@gnu.org> <20181031160729.GB20575@ACM> <83muquhyuo.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1541069489 7672 195.159.176.226 (1 Nov 2018 10:51:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Nov 2018 10:51:29 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Achim Gratz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 01 11:51:25 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 1gIAZQ-0001rP-3k for ged-emacs-devel@m.gmane.org; Thu, 01 Nov 2018 11:51:24 +0100 Original-Received: from localhost ([::1]:41291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIAbW-0007zc-Ce for ged-emacs-devel@m.gmane.org; Thu, 01 Nov 2018 06:53:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIALL-0003Xm-Qb for emacs-devel@gnu.org; Thu, 01 Nov 2018 06:36:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIALH-0005EM-GI for emacs-devel@gnu.org; Thu, 01 Nov 2018 06:36:51 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:41084 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gIALH-0005CK-69 for emacs-devel@gnu.org; Thu, 01 Nov 2018 06:36:47 -0400 Original-Received: (qmail 55682 invoked by uid 3782); 1 Nov 2018 10:36:44 -0000 Original-Received: from acm.muc.de (p5B1479F1.dip0.t-ipconnect.de [91.20.121.241]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 01 Nov 2018 11:36:43 +0100 Original-Received: (qmail 4551 invoked by uid 1000); 1 Nov 2018 10:36:33 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.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:230941 Archived-At: Hello, Achim. On Thu, Nov 01, 2018 at 09:36:54 +0100, Achim Gratz wrote: > Am 31.10.2018 um 17:20 schrieb Eli Zaretskii: > > I think we can do better in this part: > > Evaluate BODY with bindings made by matching PATTERN to each > > element of LIST in turn. PATTERN is a pcase pattern > > I think using "matching" here is detrimental to understanding what's > > going on, which is a destructuring binding that uses pcase patterns. > > (The "matching" here is between the structures of PATTERN and elements > > of LIST, but the usual meaning of "matching" in Emacs is different, > > especially when "patterns" are mentioned nearby. So we should not use > > "matching" here, at least not without significant qualifiers, like > > "structure matching" or somesuch.) > > And this: > > Should the matching fail for any LIST element, the results are > > undefined. > > should be reworded to explain that elements of LIST should have a > > structure compatible with PATTERN, so that the destructuring works. > How about this: > PATTERN describes the expected structure of LIST and is used to > establish bindings to corresponding elements of LIST during evaluation > of BODY. Undefined behaviour results if the structure of LIST is > different from that described by PATTERN. That doesn't say clearly that BODY is executed once for each LIST element. I would also go for "... the expected structure of each LIST element ..." and "... bindings of the corresponding parts of the element during ....". And one or two other changes. That would give something like this: (pcase-dolist (PATTERN LIST) BODY...) Loop over a list, evaluating BODY for each element of LIST in turn. PATTERN describes the expected structure of each LIST element and is used to establish bindings to the corresponding parts of the element during the evaluation of BODY. Undefined behavior results if the structure of any LIST element is different from PATTERN. For a description of PATTERNs, see `pcase'. See also `dolist'. What do you think? > -- > Achim. -- Alan Mackenzie (Nuremberg, Germany).