From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: The poor state of documentation of pcase like things. Date: Sun, 03 Jan 2016 18:15:48 +0100 Message-ID: <87egdy8tyz.fsf@fencepost.gnu.org> References: <20151216202605.GA3752@acm.fritz.box> <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> <871t9yk98g.fsf@fencepost.gnu.org> <568936F0.3060505@yandex.ru> <87wprqitj5.fsf@fencepost.gnu.org> <56893C8C.3060200@yandex.ru> <87oad2irtd.fsf@fencepost.gnu.org> <5689456A.1010601@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1451842146 12508 80.91.229.3 (3 Jan 2016 17:29:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jan 2016 17:29:06 +0000 (UTC) Cc: michael_heerdegen@web.de, Eli Zaretskii , Daniel Colascione , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 03 18:29:05 2016 Return-path: Envelope-to: ged-emacs-devel@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 1aFmSm-00058z-85 for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 18:29:04 +0100 Original-Received: from localhost ([::1]:42382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFmSl-00050c-LZ for ged-emacs-devel@m.gmane.org; Sun, 03 Jan 2016 12:29:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFmSh-0004wc-BS for emacs-devel@gnu.org; Sun, 03 Jan 2016 12:29:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFmSg-0003D2-E8 for emacs-devel@gnu.org; Sun, 03 Jan 2016 12:28:59 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFmSX-0003Au-Mp; Sun, 03 Jan 2016 12:28:49 -0500 Original-Received: from localhost ([127.0.0.1]:42172 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1aFmSW-00083z-O4; Sun, 03 Jan 2016 12:28:49 -0500 Original-Received: by lola (Postfix, from userid 1000) id 3E059DF87E; Sun, 3 Jan 2016 18:15:49 +0100 (CET) In-Reply-To: <5689456A.1010601@yandex.ru> (Dmitry Gutov's message of "Sun, 3 Jan 2016 17:59:38 +0200") 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-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:197472 Archived-At: Dmitry Gutov writes: > On 01/03/2016 05:52 PM, David Kastrup wrote: > >> More like "easier" to just use the _only_ documented kind of quote for >> pcase everywhere. > > From pcase docstring: > > 'VAL matches if the object is =E2=80=98equal=E2=80=99 to VAL Congratulations. From To compare a particular value against various possible cases, the macro pcase can come handy. It takes the following form: (pcase exp branch1 branch2 branch3 =E2=80=A6) where each branch takes the form (upattern body-forms=E2=80=A6). It will first evaluate exp and then compare the value against each upattern to see which branch to use, after which it will run the corresponding body-forms. A common use case is to distinguish between a few different constant values: (pcase (get-return-code x) (`success (message "Done!")) (`would-block (message "Sorry, can't do it now")) (`read-only (message "The shmliblick is read-only")) (`access-denied (message "You do not have the needed rights")) (code (message "Unknown return code %S" code))) In the last clause, code is a variable that gets bound to the value that was returned by (get-return-code x). And so forth and so on. The whole documentation idea of "qpattern" and "upattern" does not even _allow_ discussing different ways of quoting (since of course '-quoted entries are different from "qpatterns" as they don't interpret unquote and unquote-splicing, namely , and ,@) so the Elisp manual entry, arguably the decisive reference for use of pcase, actively avoids mentioning ' at all in order not to have to upset its terminology. This is not helpful, as witnessed by the actual code extracts seen in the Emacs code base and mailing list. --=20 David Kastrup