From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.tangents Subject: Re: The poor state of documentation of pcase like things. Date: Sun, 03 Jan 2016 15:50:39 +0100 Message-ID: <871t9yk98g.fsf@fencepost.gnu.org> References: <20151216202605.GA3752@acm.fritz.box> <87io3m60bq.fsf@web.de> <877fk1nnk0.fsf@web.de> <8760zlue3j.fsf@gmail.com> <87vb7kajgv.fsf@web.de> <83y4c9ag06.fsf@gnu.org> <87bn95m9eg.fsf@fencepost.gnu.org> <5686CDFB.2010105@dancol.org> <83fuygcs5g.fsf@gnu.org> <56886E32.70305@yandex.ru> <83si2f9ve4.fsf@gnu.org> <56889EC3.3040108@yandex.ru> <877fjrkpdf.fsf@fencepost.gnu.org> <56892334.4000106@yandex.ru> <8760zakb7q.fsf@fencepost.gnu.org> <56892BDA.6060103@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1451833937 22901 80.91.229.3 (3 Jan 2016 15:12:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 15:12:17 +0000 (UTC) Cc: michael_heerdegen@web.de, Eli Zaretskii , emacs-tangents@gnu.org, Dmitry Gutov To: Daniel Colascione Original-X-From: emacs-tangents-bounces+get-emacs-tangents=m.gmane.org@gnu.org Sun Jan 03 16:12:16 2016 Return-path: Envelope-to: get-emacs-tangents@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aFkKN-0005J8-O6 for get-emacs-tangents@m.gmane.org; Sun, 03 Jan 2016 16:12:15 +0100 Original-Received: from localhost ([::1]:41864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFkKM-0001aM-VQ for get-emacs-tangents@m.gmane.org; Sun, 03 Jan 2016 10:12:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFjzc-0004mR-Ur for emacs-tangents@gnu.org; Sun, 03 Jan 2016 09:50:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFjzb-0002DI-OB for emacs-tangents@gnu.org; Sun, 03 Jan 2016 09:50:48 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFjzU-0002Bm-Ao; Sun, 03 Jan 2016 09:50:40 -0500 Original-Received: from localhost ([127.0.0.1]:38351 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1aFjzT-0000Kb-Gu; Sun, 03 Jan 2016 09:50:39 -0500 Original-Received: by lola (Postfix, from userid 1000) id 0F7FEDF551; Sun, 3 Jan 2016 15:50:39 +0100 (CET) In-Reply-To: <56892BDA.6060103@dancol.org> (Daniel Colascione's message of "Sun, 3 Jan 2016 06:10:34 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) 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-Mailman-Approved-At: Sun, 03 Jan 2016 10:12:11 -0500 X-BeenThere: emacs-tangents@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-tangents-bounces+get-emacs-tangents=m.gmane.org@gnu.org Original-Sender: emacs-tangents-bounces+get-emacs-tangents=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.tangents:66 Archived-At: Daniel Colascione writes: > On 01/03/2016 06:07 AM, David Kastrup wrote: >> Dmitry Gutov writes: >> >>> On 01/03/2016 11:02 AM, David Kastrup wrote: >>> >>>> Uh what? Whether pcase does not help with simple cases should have >>>> little bearing on whether it helps with more complex cases. >>> >>> But it does. It takes less code, >> >> You mean, less input. > > A side effect of a more expressive system. > >>> and follows the common design of pattern matching, which isn't hard to >>> understand and internalize. >> >> And yet Emacs has more than just regexp operations for dealing with >> strings, and most string operations are carried out without reverting to >> regexps. >> >>> In the more complex cases, the syntax may have some thorns, >> >> Then it's not doing a good job of reducing complexity. If it requires >> me to use quasiquote for stuff that contains neither unquote nor >> unquote-splicing (and has no sensible interpretation of unquote-splicing >> in connection with its own use of quasiquote anyway), it does a bad >> human interfacing job. Why do I need to quote self-quoting expressions >> at all? And why do self-quoting symbols differ in meaning when preceded >> by quasiquote? In Lisp, `nil is equivalent to nil . That's not what >> pcase sees, I think. > > I find pcase quite readable; it's not going away. So it should not get fixed or made more consistent with expectations? > Honestly, I also found the existing documentation completely adequate. The problem is that its underlying design principle, matching quoted stuff structurally/literally and using unquoted symbols as variable names, is only implemented in a cursory manner. That means that reading a pcase expression and understanding what it does does not enable you to fix it with confidence or write your own. Its forced use of `quasiquote' where `quote' would suffice were it properly implemented is a contributor to the "there must be something non-obvious going on" impression. Scheme has the somewhat similar pattern matching library by Andrew Wright but it does not make the design mistake of using quasiquote while ignoring quote. People don't use it as a control structure replacement, however, in spite of it being more coherent and powerful than Emacs' pcase. It is used when needed and/or appropriate. Which is perfectly fine. For example, matching patterns in the byte compiler would be an excellent case for working with matching/binding constructs of that kind. Indeed, Scheme's more "modern" replacement of the macro system, syntax forms, tends to be used for a lot of code in Scheme interpreters/compilers (particularly in GUILE-2.x, incidentally a significant contributing factor to its abysmal bootstrapping performance as the bootstrapping variant does not scale to the task) and is also of somewhat similar kind. But syntax-case system, while based on similarly syntaxed elements, is quite different from a particular expression matcher as it basically is used to extend one large global pattern matcher used for eval rather than doing a single matching operation per call. -- David Kastrup