diff options
| author | Noam Postavsky | 2018-03-31 00:40:43 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-03-31 00:50:37 -0400 |
| commit | e50196e8a96216f1fd69f9257cddd8d76ad2ac78 (patch) | |
| tree | 0cc120b6a633ce87db822016922c1df4976f2f65 /lisp | |
| parent | 8a2466ff7240136c32b1cc21143225935d462cc6 (diff) | |
| download | emacs-e50196e8a96216f1fd69f9257cddd8d76ad2ac78.tar.gz emacs-e50196e8a96216f1fd69f9257cddd8d76ad2ac78.zip | |
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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/pcase.el | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 6cfd074cf0b..ce148c9e1a9 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 | |||
| 118 | 118 | ||
| 119 | A significant difference from `cl-destructuring-bind' is that, if | 119 | A significant difference from `cl-destructuring-bind' is that, if |
| 120 | a pattern match fails, the next case is tried until either a | 120 | a pattern match fails, the next case is tried until either a |
| 121 | successful match is found or there are no more cases. | 121 | successful match is found or there are no more cases. The CODE |
| 122 | expression corresponding to the matching pattern determines the | ||
| 123 | return value. If there is no match the returned value is nil. | ||
| 122 | 124 | ||
| 123 | Another difference is that pattern elements may be quoted, | 125 | Another difference is that pattern elements may be quoted, |
| 124 | meaning they must match exactly: The pattern \\='(foo bar) | 126 | meaning they must match exactly: The pattern \\='(foo bar) |
| @@ -211,7 +213,8 @@ Emacs Lisp manual for more information and examples." | |||
| 211 | 213 | ||
| 212 | ;;;###autoload | 214 | ;;;###autoload |
| 213 | (defmacro pcase-exhaustive (exp &rest cases) | 215 | (defmacro pcase-exhaustive (exp &rest cases) |
| 214 | "The exhaustive version of `pcase' (which see)." | 216 | "The exhaustive version of `pcase' (which see). |
| 217 | If EXP fails to match any of the patterns in CASES, an error is signaled." | ||
| 215 | (declare (indent 1) (debug pcase)) | 218 | (declare (indent 1) (debug pcase)) |
| 216 | (let* ((x (gensym "x")) | 219 | (let* ((x (gensym "x")) |
| 217 | (pcase--dontwarn-upats (cons x pcase--dontwarn-upats))) | 220 | (pcase--dontwarn-upats (cons x pcase--dontwarn-upats))) |