From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Replace trivial pcase occurrences in the Emacs sources Date: Wed, 31 Oct 2018 18:20:31 +0200 Message-ID: <83muquhyuo.fsf@gnu.org> References: <83r2g7jrot.fsf@gnu.org> <83k1lzjq0r.fsf@gnu.org> <83in1jjmy4.fsf@gnu.org> <20181031120821.GA20575@ACM> <831s86jey9.fsf@gnu.org> <20181031160729.GB20575@ACM> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1541002814 1826 195.159.176.226 (31 Oct 2018 16:20:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Oct 2018 16:20:14 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 31 17:20:09 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 1gHtE1-0000MI-K1 for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 17:20:09 +0100 Original-Received: from localhost ([::1]:60557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtG7-0003am-ND for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 12:22:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtEa-0003Z1-QY for emacs-devel@gnu.org; Wed, 31 Oct 2018 12:20:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHtEX-0003tN-C9 for emacs-devel@gnu.org; Wed, 31 Oct 2018 12:20:44 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtEW-0003op-8h; Wed, 31 Oct 2018 12:20:41 -0400 Original-Received: from [176.228.60.248] (port=2490 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gHtER-0007uY-UK; Wed, 31 Oct 2018 12:20:37 -0400 In-reply-to: <20181031160729.GB20575@ACM> (message from Alan Mackenzie on Wed, 31 Oct 2018 16:07:29 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:230883 Archived-At: > Date: Wed, 31 Oct 2018 16:07:29 +0000 > Cc: Stefan Monnier , emacs-devel@gnu.org > From: Alan Mackenzie > > > I will try, if no one beats me to it. > > A beating attempt, first draught: > > (pcase-dolist (PATTERN LIST) BODY...) > > Loop over a list. > > Evaluate BODY with bindings made by matching PATTERN to each > element of LIST in turn. PATTERN is a pcase pattern, the > matching being done as described in `pcase'. The return value is > not significant. > > Should the matching fail for any LIST element, the results are > undefined. > > See also `dolist' Thanks. 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.