emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 e50196e 1/2: Document return value of pcase (Bug#


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 e50196e 1/2: Document return value of pcase (Bug#30425)
Date: Sat, 31 Mar 2018 01:01:08 -0400 (EDT)

branch: emacs-26
commit e50196e8a96216f1fd69f9257cddd8d76ad2ac78
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Document return value of pcase (Bug#30425)
    
    * doc/lispref/control.texi (Pattern matching case statement):
    * lisp/emacs-lisp/pcase.el (pcase): State that pcase returns nil if no
    patterns match.
    (pcase-exhaustive): State that an error is signaled if no patterns
    match.
---
 doc/lispref/control.texi | 3 ++-
 lisp/emacs-lisp/pcase.el | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index f85ee94..adec632 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -317,7 +317,8 @@ list of the form @code{(@var{pattern} @address@hidden)}.
 @var{pattern} of each clause, in textual order.  If the value matches,
 the clause succeeds; @code{pcase} then evaluates its @var{body-forms},
 and returns the value of the last of @var{body-forms}.  Any remaining
address@hidden are ignored.
address@hidden are ignored.  If no clauses match, then the @code{pcase}
+form evaluates to @code{nil}.
 
 The @var{pattern} part of a clause can be of one of two types:
 @dfn{QPattern}, a pattern quoted with a backquote; or a
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 6cfd074..ce148c9 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -118,7 +118,9 @@ two element list, binding its elements to symbols named 
`foo' and
 
 A significant difference from `cl-destructuring-bind' is that, if
 a pattern match fails, the next case is tried until either a
-successful match is found or there are no more cases.
+successful match is found or there are no more cases.  The CODE
+expression corresponding to the matching pattern determines the
+return value.  If there is no match the returned value is nil.
 
 Another difference is that pattern elements may be quoted,
 meaning they must match exactly: The pattern \\='(foo bar)
@@ -211,7 +213,8 @@ Emacs Lisp manual for more information and examples."
 
 ;;;###autoload
 (defmacro pcase-exhaustive (exp &rest cases)
-  "The exhaustive version of `pcase' (which see)."
+  "The exhaustive version of `pcase' (which see).
+If EXP fails to match any of the patterns in CASES, an error is signaled."
   (declare (indent 1) (debug pcase))
   (let* ((x (gensym "x"))
          (pcase--dontwarn-upats (cons x pcase--dontwarn-upats)))



reply via email to

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