From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Update of pcase docs for the elisp manual
Date: Mon, 25 Jan 2016 18:14:23 +0200 [thread overview]
Message-ID: <83egd53acg.fsf@gnu.org> (raw)
In-Reply-To: <jwva8nu1sve.fsf-monnier+gmane.emacs.devel@gnu.org> (message from Stefan Monnier on Sun, 24 Jan 2016 18:17:10 -0500)
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Sun, 24 Jan 2016 18:17:10 -0500
>
> >> > . The exact syntax and possible forms of QPatterns are described
> >> > ambiguously and seemingly incompletely, and profoundly contradict
> >> > almost every given example of them. Both Michael and the previous
> >> > manual text describe them as follows:
> >> >
> >> > The form is `QPAT where QPAT is one of the following:
> >> >
> >> > (QPAT1 . QPAT2)
> >> > [QPAT1 QPAT2 ... QPATn]
> >> > ,PAT
> >> > ATOM
> >> >
> >> > The last two look wrong: AFAIU, there is no QPattern of the form
> >> > `,PATH
> >>
> >> I think `,PAT is a valid UPattern, which is simply equivalent to PAT.
> >>
> >> > or `ATOM.
> >>
> >> And `ATOM is also a valid UPattern.
> > The above describes QPatterns, not UPatterns.
>
> Yes, the ` pcase-macro introduces a new kind of patterns (the
> QPatterns) which are those that appear under the ` .
>
> So when I say that `ATOM is a valid UPattern, it means that ATOM is
> a valid QPattern. And similarly when I say that "`,PAT is a valid
> UPattern" it means that ",PAT" is a valid QPattern.
What I wrote in the manual uses the reverse notation: QPatterns
_include_ the backquote. The reason for adopting this notation was
that every time QPatterns are used, the backquote is there. So IMO
the description makes more sense the way I wrote it.
> The QPattern and UPattern languages are not mutually exclusive: you
> can't tell by looking at a pattern if it's a QPattern or a UPattern.
> Instead, the context (whether it's within a ` or not) determines which
> of the two is expected.
That's not an important distinction for using the languages, IMO. I
understand how it can be important for someone who knows the
implementation very well.
> >> Of course it does: `(A B C D ...) is 100% equivalent to
> >> `(A . (B . (C . (D . ...)))) and (QPAT1 . QPAT2) is a QPAT.
> > Which IMO means we must add the likes of `(A B C D) to the manual,
> > because expecting the readers of software documentation to solve
> > riddles as they read is not a good idea.
>
> Agreed. Not needed for the docstring (which is more meant as
> a reference for people who already know how it works, and needs to be
> both exhaustive and concise), but useful for the manual.
My quotation was not from the doc string, but from Michael's tutorial.
> >> > . Last, but not least: NEWS says we now have a new UPattern 'quote',
> >> > but neither John, nor Michael or the doc strings mention this
> >> > pattern. What did I miss?
> >> The docstring says:
> >> 'VAL matches if the object is ‘equal’ to VAL.
> >> and 'VAL is also spelled (quote VAL).
> > This probably means that 'quote' shouldn't be documented as a separate
> > pattern, as that is a technicality which is much more likely to
> > confuse than to help understanding.
>
> Just like the (A B C) vs (A . (B . (C . nil))) issue, 'A is one and the
> same as (quote A), so it's definitely not a separate pattern.
We can certainly point out the difference between A and 'A in this
context, but I see no reason to document 'quote' as a separate pattern.
> > Unless, that is, there are important scenarios where using (quote FOO)
> > in a pattern is required where it isn't a trivial replacement
> > for 'FOO.
>
> A macro (such as pcase) can never distinguish 'A from (quote A) since
> the reader returns exactly the same result either way.
Sorry, is that a no?
next prev parent reply other threads:[~2016-01-25 16:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m2fuxq6pb0.fsf@newartisans.com>
[not found] ` <87d1stznc6.fsf@web.de>
[not found] ` <m2si1p8r31.fsf@newartisans.com>
[not found] ` <m2powt5w50.fsf@newartisans.com>
2016-01-23 11:17 ` Update of pcase docs for the elisp manual Eli Zaretskii
2016-01-24 4:40 ` Stefan Monnier
2016-01-24 14:33 ` Eli Zaretskii
2016-01-24 23:17 ` Stefan Monnier
2016-01-25 16:14 ` Eli Zaretskii [this message]
2016-01-26 1:40 ` Stefan Monnier
2016-01-26 15:38 ` Eli Zaretskii
2016-01-26 16:23 ` Stefan Monnier
2016-01-25 14:22 ` Michael Heerdegen
2016-01-25 14:15 ` Michael Heerdegen
2016-01-25 16:33 ` Eli Zaretskii
2016-01-28 18:37 ` Michael Heerdegen
2016-01-29 3:06 ` Stefan Monnier
2016-01-29 9:45 ` Eli Zaretskii
2016-01-29 14:51 ` Michael Heerdegen
2016-01-26 16:59 ` John Wiegley
2016-01-26 18:10 ` Stefan Monnier
2016-01-26 18:41 ` Eli Zaretskii
2016-01-26 19:35 ` John Wiegley
2016-01-26 20:28 ` Eli Zaretskii
2016-01-29 1:28 ` John Wiegley
2016-01-29 8:30 ` Eli Zaretskii
2016-01-29 13:39 ` Andy Moreton
2016-01-29 14:21 ` Eli Zaretskii
2016-01-29 15:14 ` Andy Moreton
2016-01-29 15:37 ` Eli Zaretskii
2016-01-26 19:58 ` Andy Moreton
2016-01-26 20:19 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83egd53acg.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).