unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Update of pcase docs for the elisp manual
Date: Tue, 26 Jan 2016 11:23:38 -0500	[thread overview]
Message-ID: <jwvio2gtj0d.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 83k2mw1hcl.fsf@gnu.org

>> >> > 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?
>> It's not just a "no", it's a "no, because it's impossible".
>> I thought that would be obvious to a seasoned Lisper like you, but
>> clearly it isn't so we need to say it more explicitly.
> pcase isn't Lisp, it's a macro that assigns different meanings to some
> Lisp constructs.

But it's defined as a macro in Lisp.  Macros in Lisp do not see the
source code's text, they only see the Sexp representation, so just like
they can't see how much whitespace or which comments were present, they
can't distinguish 'foo from (quote foo) since they're both turned by the
Lisp reader into a cons cells with the symbol `quote' in the car.

>> -The @var{pattern} part of a clause can be of one of two types:
>> -@dfn{QPattern}, a pattern quoted with a backquote; or a
>> -@dfn{UPattern}, which is not quoted.  UPatterns are simpler, so we
>> -describe them first.
> If we use "backquoted patterns" here, the rest does have a purpose,
> and removing it diminishes the ease of reading, I think.  The purpose
> of this was to provide some outlook on the issue that's about to be
> described.

OK.

>> -The QPatterns are more powerful.  They allow matching the value of the
>> -@var{expression} that is the first argument of @code{pcase} against
>> -specifications of its @emph{structure}.  For example, you can specify
>> -that the value must be a list of 2 elements whose first element is a
>> -string and the second element is a number.  QPatterns can have one of
>> -the following forms:
>> +@node Pcase with backquotes
>> +@subsubsection Pcase with backquotes
>> +
>> +Additionally to the above patterns, one can also use a backquoted
>> +pattern.  This facility is designed with the idea that a backquoted
>> +pattern should match all values that could be constructed
>> +by a similarly backquoted expression.  For example, you can specify
>> +that the value must be a list of 2 elements whose first element is the
>> +string @code{"first"} with a pattern like @code{`("first" ,elem)}.

> I agree that your example is better, but why the other changes?  Why
> is it important to tell the reader the design idea?

I thought it would be good to try and give them an intuition that
hopefully helps them see the correspondance between the normal backquote
macro and the pcase backquote macro.

> I also don't think further dividing this sub-section into
> sub-sub-sections is a good idea: there are less than 200 lines in it,
> so it's not too large.  The last sub-sub-section you holds just 6
> lines, way to few to justify a separate unit, I think.

OK.

> In general, subdividing into nodes breaks the continuity of
> description, so it's only justified for significant portions or for
> some obscure aspect (like an extended footnote), or for almost
> entirely unrelated subjects.  None of that happens here, I think.

I guess I like structure more than the average human.


        Stefan




  reply	other threads:[~2016-01-26 16:23 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
2016-01-26  1:40                 ` Stefan Monnier
2016-01-26 15:38                   ` Eli Zaretskii
2016-01-26 16:23                     ` Stefan Monnier [this message]
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=jwvio2gtj0d.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /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).