[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The poor state of documentation of pcase like things.
From: |
David Kastrup |
Subject: |
Re: The poor state of documentation of pcase like things. |
Date: |
Sun, 03 Jan 2016 18:15:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Dmitry Gutov <address@hidden> 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 ‘equal’ to VAL
Congratulations. From
<URL:https://www.gnu.org/software/emacs/manual/html_node/elisp/Pattern-matching-case-statement.html#index-pcase>
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 …)
where each branch takes the form (upattern body-forms…).
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.
--
David Kastrup
- Re: The poor state of documentation of pcase like things., (continued)
- Re: The poor state of documentation of pcase like things., David Kastrup, 2016/01/03
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/02
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/02
- Re: The poor state of documentation of pcase like things., Noam Postavsky, 2016/01/02
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/02
- Re: The poor state of documentation of pcase like things., John Wiegley, 2016/01/02
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/02
- Re: The poor state of documentation of pcase like things., Eli Zaretskii, 2016/01/02
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Re: The poor state of documentation of pcase like things., David Kastrup, 2016/01/03
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/03
- Re: The poor state of documentation of pcase like things.,
David Kastrup <=
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/03
- Re: The poor state of documentation of pcase like things., David Kastrup, 2016/01/03
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/03
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/04
- Re: The poor state of documentation of pcase like things., John Wiegley, 2016/01/04
- Re: The poor state of documentation of pcase like things., Eli Zaretskii, 2016/01/04
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/03
- Re: The poor state of documentation of pcase like things., Richard Copley, 2016/01/01
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/01
RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/01