unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 31311@debbugs.gnu.org
Subject: bug#31311: 27.0; doc of `pcase'
Date: Sun, 29 Apr 2018 09:03:32 -0700 (PDT)	[thread overview]
Message-ID: <b5d5bbd5-f90c-4836-9307-7a74ad0b2320@default> (raw)

1. Please rename Elisp manual node `Pattern matching case statement'.
   It should use Title Case (not Sentence case), like the other nodes.
   And do not refer to "case", as the other index entries that match
   `case' have nothing to do with conditionals.  And the node name can
   be shorter, e.g., `Pattern-Matching Conditional'.

2. Don't use ATOM unless you mean any atom, even if you explain
   subsequently that you really mean a self-evaluating atom.  In
   particular, an arbitrary symbol is an atom, and (especially if ATOM
   is described before SYMBOL) ATOM would seem to cover the SYMBOL case,
   which it does not.  Just use "CONSTANT" instead of "ATOM".  AFAIK,
   every self-evaluating sexp in Emacs Lisp satisfies `atomp' (but not
   everything that satisfies `atomp' is a self-evaluating sexp).

   The doc should also make clear whether the ATOM clause covers a
   symbol defined using `defconst'.  The answer seems to be no; it
   seems to be covered instead by the SYMBOL clause.

3. The doc string (but not the Elisp manual, node `Pattern matching case
   statement') refers to "the object" without ever specifying what it
   is.  This makes all of the specifications that use "the object"
   meaningless: 'VAL, (pred FUN), and (app FUN PAT).

   The manual uses "the value being matched" instead, which is OK
   (understandable).  Still, it would be clearer to give a name to "the
   value being matched" at the beginning: EXPVAL, for example, at the
   place where you say, "based on the value of EXPRESSION".

   Similarly, replace "value of the EXPRESSION that is the first
   argument of 'pcase'" by the name you give that (e.g. EXPVAL).

4. The doc string seems to be describing a different animal from the
   manual.  Try to harmonize the two descriptions, including wrt the
   order of pattern presentation.

5. Don't use "QPattern" and "UPattern".  Use "Q pattern" and "U
   pattern", or (probably better) "Q-pattern" and "U-pattern".

6. This part of the description of `guard' is unclear, to me:

   For example ... and let-binds the variable 'x' to that number.

   I see nothing in the descriptions of `guard' and `and' that indicates
   why `x' would be let-bound in this example.

7. The doc-string descriptions do not correspond to those in the manual,
   in several cases.  E.g. (app FUN PAT) is different from (app FUNCTION
   UPATTERN).  Is the pattern necessarily a U-pattern?  Similary for
   `or' etc.

8. Please check for typos.  E.g., "Matches if one the argument UPatterns
   matches."

9. This is not clear to m: "For this reason, if any of the UPatterns
   let-bind symbols to the matched value, they should all bind the same
   symbols."  Should it instead say that they should all bind the same
   symbols to the matched value"?  Also, does a similar thing need to be
   said for `and'?

10. This text: "The function calls used in the 'pred' and 'app'
    UPatterns can have one of the following forms" seems wrong.
    Presumably what it is trying to say is that PREDFUN and FUNCTION
    "can have one of the following forms".  Those forms are not
    necessarily function calls.  Similarly, for the text "The FUNCTION
    call can use one of the forms described below" - just say "FUNCTION
    can use...", not "The FUNCTION call can use...".

11. Do not say "lambda-function".  Say either "lambda expression" or
    "anonymous function".  There is no such thing as a lambda function.
    You might also want to xref node `Lambda Expressions'.

12. "Here is an illustrative example" -> "Here is an example".

13. "you can use backquoted patterns that are more powerful" -> "you can
    use backquoted patterns, which that are more powerful".  The comma
    is important.  This part of the node is not "in addition" to some
    previous description of backquoted patterns; this _is_ the
    description of backquoted patterns, i.e., Q-patterns.  What came
    before was the description of unquoted patterns, i.e., U-patterns.

14. "(note that this example requires lexical binding, *note Lexical
    Binding::)".  Say _why_ this is the case, not just that it is true.
    Why does it require lexical binding?

    Also, the code needs wrapping; two of the lines are too long:

    (funcall (evaluate fun env) (evaluate arg env)) ->
    (funcall (evaluate fun env)
             (evaluate arg env))

    (lambda (val)
      (evaluate body (cons (cons arg val) env))) ->

    (lambda (val)
      (evaluate body
                (cons (cons arg val) env)))

15. Break up the paragraph that begins "Here '`(add ,x ,y)' is a..."

16. All of the following text in the _doc string_ is pretty much
   incomprehensible, to me.  It's not clear what it's trying to say or
   even, in some cases, how it relates to `pcase' at all.  And most of
   it seems to have no correspondence in the manual.

   -- (radix-tree-leaf VPAT)

   Not documented.

   -- (cl-struct TYPE &rest FIELDS)

   Pcase patterns to match cl-structs.
   Elements of FIELDS can be of the form (NAME PAT) in which case the
   contents of field NAME is matched against PAT, or they can be of the
   form NAME which is a shorthand for (NAME NAME).

   -- (seq &rest PATTERNS)

   Build a 'pcase' pattern that matches elements of SEQUENCE.

   The 'pcase' pattern will match each element of PATTERNS against the
   corresponding element of SEQUENCE.

   Extra elements of the sequence are ignored if fewer PATTERNS are
   given, and the match does not fail.

   -- (eieio &rest FIELDS)

   Pcase patterns to match EIEIO objects.
   Elements of FIELDS can be of the form (NAME PAT) in which case the
   contents of field NAME is matched against PAT, or they can be of the
   form NAME which is a shorthand for (NAME NAME).

   -- `QPAT

   Backquote-style pcase patterns.
   QPAT can take the following forms:
     (QPAT1 . QPAT2)       matches if QPAT1 matches the car and QPAT2 the cdr.
     [QPAT1 QPAT2..QPATn]  matches a vector of length n and QPAT1..QPATn match
                              its 0..(n-1)th elements, respectively.
     ,PAT                  matches if the pcase pattern PAT matches.
     ATOM                  matches if the object is 'equal' to ATOM.
                              ATOM can be a symbol, an integer, or a string.

In GNU Emacs 27.0.50 (build 3, x86_64-w64-mingw32)
 of 2018-03-21
Repository revision: e70d0c9e66d7a8609450b2889869d16aeb0363b5
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install -C 'CFLAGS=-O2 -static -g3''





             reply	other threads:[~2018-04-29 16:03 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-29 16:03 Drew Adams [this message]
2018-04-29 16:39 ` bug#31311: 27.0; doc of `pcase' Eli Zaretskii
2018-04-29 18:31   ` Michael Heerdegen
2018-04-29 18:45     ` Eli Zaretskii
2018-04-29 20:05       ` Michael Heerdegen
2018-04-30  2:36         ` Eli Zaretskii
2018-04-30 11:20           ` Noam Postavsky
2018-04-30 13:35             ` Thien-Thi Nguyen
2018-04-30 16:58               ` Drew Adams
2018-04-30 18:04               ` Michael Heerdegen
2018-05-01  9:41                 ` Thien-Thi Nguyen
2018-04-30 19:31               ` Eli Zaretskii
2018-05-12 11:18                 ` Thien-Thi Nguyen
2018-05-12 13:54                   ` Michael Heerdegen
2018-05-15 14:24                     ` Thien-Thi Nguyen
2018-05-15 15:16                       ` Michael Heerdegen
2018-05-16 10:43                         ` Thien-Thi Nguyen
2018-05-16 15:18                           ` Michael Heerdegen
2018-05-20 18:59                             ` Thien-Thi Nguyen
2018-05-23 13:55                               ` Drew Adams
2018-05-23 15:42                                 ` Eli Zaretskii
2018-05-23 15:28                               ` Eli Zaretskii
2018-05-23 19:16                                 ` Thien-Thi Nguyen
2018-05-24 16:23                                   ` Eli Zaretskii
2018-05-26  7:58                                     ` Thien-Thi Nguyen
2018-05-24 23:13                                   ` Noam Postavsky
2018-05-26  9:01                                     ` Thien-Thi Nguyen
2018-05-26 15:26                                       ` Drew Adams
2018-05-27  8:22                                         ` Thien-Thi Nguyen
2018-05-27  8:41                                           ` Thien-Thi Nguyen
2018-05-27 13:31                                           ` Drew Adams
2018-05-27 14:12                                           ` Noam Postavsky
2018-05-27 16:16                                           ` Eli Zaretskii
2018-05-27 16:26                                             ` Eli Zaretskii
2018-05-27 16:32                                               ` Andreas Schwab
2018-05-27 17:30                                                 ` Eli Zaretskii
2018-05-27 17:45                                                   ` Andreas Schwab
2018-05-27 17:42                                               ` Thien-Thi Nguyen
2018-05-28  7:25                                               ` Nicolas Petton
2018-05-28  7:33                                                 ` Nicolas Petton
2018-05-28  8:27                                                 ` Eli Zaretskii
2018-05-28  9:32                                                   ` Nicolas Petton
2018-05-12 13:56                   ` Noam Postavsky
2018-05-15 14:37                     ` Thien-Thi Nguyen
2019-08-25 12:56               ` Michael Heerdegen
2018-04-30 14:28             ` Eli Zaretskii
2018-04-29 22:59 ` Drew Adams
2018-04-29 23:16   ` Noam Postavsky
2018-04-29 23:28     ` Drew Adams
2018-04-30  0:29 ` Michael Heerdegen
2018-04-30  2:47   ` Drew Adams
2018-04-30  7:48     ` Thien-Thi Nguyen
2018-05-21 17:04 ` Thien-Thi Nguyen
2022-04-29 13:48 ` Lars Ingebrigtsen
2022-04-29 14:39   ` Drew Adams
     [not found] <<b5d5bbd5-f90c-4836-9307-7a74ad0b2320@default>
     [not found] ` <<83wowqrmp8.fsf@gnu.org>
2018-04-29 17:02   ` Drew Adams
2018-04-29 17:16     ` Eli Zaretskii
2018-04-29 18:38     ` Michael Heerdegen
2018-04-29 19:43       ` Drew Adams
2018-04-29 20:00         ` Michael Heerdegen
     [not found] <<<b5d5bbd5-f90c-4836-9307-7a74ad0b2320@default>
     [not found] ` <<<83wowqrmp8.fsf@gnu.org>
     [not found]   ` <<9cd18e10-8f14-4a49-a3a4-ed9d50afe860@default>
     [not found]     ` <<83sh7erl01.fsf@gnu.org>
2018-04-29 17:26       ` Drew Adams

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=b5d5bbd5-f90c-4836-9307-7a74ad0b2320@default \
    --to=drew.adams@oracle.com \
    --cc=31311@debbugs.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).