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: Sat, 03 Nov 2018 18:25:37 +0200 Message-ID: <83sh0idt6m.fsf@gnu.org> References: <83r2g8klf9.fsf@gnu.org> <83wopzk3sw.fsf@gnu.org> <83r2g7jrot.fsf@gnu.org> <83k1lzjq0r.fsf@gnu.org> <83in1jjmy4.fsf@gnu.org> <20181031120821.GA20575@ACM> <831s86jey9.fsf@gnu.org> <83wopue1xl.fsf@gnu.org> <87o9b62mij.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1541262270 25441 195.159.176.226 (3 Nov 2018 16:24:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2018 16:24:30 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 03 17:24: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 1gIyim-0006WS-SW for ged-emacs-devel@m.gmane.org; Sat, 03 Nov 2018 17:24:24 +0100 Original-Received: from localhost ([::1]:56206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIykt-0006dN-3s for ged-emacs-devel@m.gmane.org; Sat, 03 Nov 2018 12:26:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIykH-0006d5-77 for emacs-devel@gnu.org; Sat, 03 Nov 2018 12:25:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIykD-0001lT-MA for emacs-devel@gnu.org; Sat, 03 Nov 2018 12:25:56 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIykD-0001lI-HR; Sat, 03 Nov 2018 12:25:53 -0400 Original-Received: from [176.228.60.248] (port=3086 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gIykC-0003u2-5t; Sat, 03 Nov 2018 12:25:53 -0400 In-reply-to: <87o9b62mij.fsf@web.de> (message from Michael Heerdegen on Sat, 03 Nov 2018 16:45:08 +0100) 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:230994 Archived-At: > From: Michael Heerdegen > Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org > Date: Sat, 03 Nov 2018 16:45:08 +0100 > > control.texi line 521 "is equals": typo. Thanks, fixed. > | The pcase patterns that are useful for destructuring bindings are > | generally those described in @ref{Backquote Patterns}, since they > | express a specification of the structure of objects that will match. > > I don't like that sentence for two reasons: > > (1) ` is the pcase pattern for destructuring. The "Backquote Patterns" > or "Backquote style Patterns" are not really "pcase patterns" since they > are part of the implicit semantics ``' defines. They are _not_ pcase > patterns. Your sentence confuses the both. Sorry, you lost me here. How can these not be pcase patterns, when they are used with 'pcase', and "pcase patterns" are _defined_ as those used with 'pcase'? > (2) We already have a lot other patterns for destructuring (eieio, seq, > map, cl-struct), and we probably will get even more in the future. OK, but why is that a reason not to use what I wrote? Note that it talks about "destructuring binding", not just about destructuring. Also please note that I made some changes in the description of seq-let to say that is an alternative facility for destructuring binding. The text you quoted doesn't say that those pcase patterns are the _only_ method of destructuring. If that is the root cause of your disliking, we could make this even more clear. > | @defmac pcase-let bindings body@dots{} > | Perform desctructuring binding of variables according to > | @var{bindings}, and then evaluate @var{body}. > > and lots of similar: > > `pcase-let', `pcase-dolist' and the like are very often used only for > destructuring, but they are not limited to destructuring. Like in > > (defun test (arg) > (pcase-let (((or (and (pred stringp) s) > (and (pred numberp) (app number-to-string s))) > arg)) > s)) > > (test "Hallo") => "Hallo" > (test 1) => "1" OK, but why would I need pcase-let in this example? Isn't the above the same as (defun test (arg) (let ((s (cond ((stringp arg) arg) ((numberp arg) (number-to-string arg))))) s)) (which is both simpler and shorter)? > Also the docstrings give the impression that these are limited to > destructuring, which is not true. Can you tell where did you get that impression? The doc strings talk about destructuring bindings, when BINDINGS have the form specified, and I believe that is true.