emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace trivial pcase occurrences in the Emacs sources


From: Michael Heerdegen
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Sat, 03 Nov 2018 16:45:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

> Done, I hope.

Great, thanks Eli.

Some comments/thoughts:

control.texi line 521 "is equals": typo.

| The pcase patterns that are useful for destructuring bindings are
| generally those described in @ref{Backquote Patterns}, since they
| express a specification of the structure of objects that will match.

I don't like that sentence for two reasons:

(1) ` is the pcase pattern for destructuring.  The "Backquote Patterns"
or "Backquote style Patterns" are not really "pcase patterns" since they
are part of the implicit semantics ``' defines.  They are _not_ pcase
patterns.  Your sentence confuses the both.

(2) We already have a lot other patterns for destructuring (eieio, seq,
map, cl-struct), and we probably will get even more in the future.

| @defmac pcase-let bindings address@hidden
| Perform desctructuring binding of variables according to
| @var{bindings}, and then evaluate @var{body}.

and lots of similar:

`pcase-let', `pcase-dolist' and the like are very often used only for
destructuring, but they are not limited to destructuring.  Like in

(defun test (arg)
  (pcase-let (((or (and (pred stringp) s)
                   (and (pred numberp) (app number-to-string s)))
               arg))
    s))

(test "Hallo") => "Hallo"
(test 1)       => "1"

Also the docstrings give the impression that these are limited to
destructuring, which is not true.


Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]