diff options
| author | Stefan Monnier | 2018-10-30 14:24:31 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-10-30 14:24:31 -0400 |
| commit | eb903d8f20ab0c31daa27a08b0acfd30115c7b5e (patch) | |
| tree | 72ef22d00690e7984c735fecd12e959d9a91e9c0 | |
| parent | 86abbb3cb8490f73eb00023cf1c9ea7b5a8fffaf (diff) | |
| download | emacs-eb903d8f20ab0c31daa27a08b0acfd30115c7b5e.tar.gz emacs-eb903d8f20ab0c31daa27a08b0acfd30115c7b5e.zip | |
* lisp/emacs-lisp/pcase.el: Improve docstrings.
| -rw-r--r-- | lisp/emacs-lisp/pcase.el | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index fa7b1de8b4d..2e89ae0779a 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el | |||
| @@ -266,7 +266,8 @@ variable name being but a special case of it)." | |||
| 266 | (defmacro pcase-let* (bindings &rest body) | 266 | (defmacro pcase-let* (bindings &rest body) |
| 267 | "Like `let*' but where you can use `pcase' patterns for bindings. | 267 | "Like `let*' but where you can use `pcase' patterns for bindings. |
| 268 | BODY should be an expression, and BINDINGS should be a list of bindings | 268 | BODY should be an expression, and BINDINGS should be a list of bindings |
| 269 | of the form (PAT EXP)." | 269 | of the form (PATTERN EXP). |
| 270 | See `pcase-let' for discussion of how PATTERN is matched." | ||
| 270 | (declare (indent 1) | 271 | (declare (indent 1) |
| 271 | (debug ((&rest (pcase-PAT &optional form)) body))) | 272 | (debug ((&rest (pcase-PAT &optional form)) body))) |
| 272 | (let ((cached (gethash bindings pcase--memoize))) | 273 | (let ((cached (gethash bindings pcase--memoize))) |
| @@ -281,10 +282,11 @@ of the form (PAT EXP)." | |||
| 281 | (defmacro pcase-let (bindings &rest body) | 282 | (defmacro pcase-let (bindings &rest body) |
| 282 | "Like `let' but where you can use `pcase' patterns for bindings. | 283 | "Like `let' but where you can use `pcase' patterns for bindings. |
| 283 | BODY should be a list of expressions, and BINDINGS should be a list of bindings | 284 | BODY should be a list of expressions, and BINDINGS should be a list of bindings |
| 284 | of the form (PAT EXP). | 285 | of the form (PATTERN EXP). |
| 285 | The macro is expanded and optimized under the assumption that those | 286 | The PATTERNs are only used to extract data, so the code does not test |
| 286 | patterns *will* match, so a mismatch may go undetected or may cause | 287 | whether the data does match the corresponding patterns: a mismatch |
| 287 | any kind of error." | 288 | may signal an error or may go undetected, binding variables to arbitrary |
| 289 | values, such as nil." | ||
| 288 | (declare (indent 1) (debug pcase-let*)) | 290 | (declare (indent 1) (debug pcase-let*)) |
| 289 | (if (null (cdr bindings)) | 291 | (if (null (cdr bindings)) |
| 290 | `(pcase-let* ,bindings ,@body) | 292 | `(pcase-let* ,bindings ,@body) |
| @@ -302,7 +304,11 @@ any kind of error." | |||
| 302 | 304 | ||
| 303 | ;;;###autoload | 305 | ;;;###autoload |
| 304 | (defmacro pcase-dolist (spec &rest body) | 306 | (defmacro pcase-dolist (spec &rest body) |
| 305 | "Like `dolist' but where the binding can be a `pcase' pattern. | 307 | "Superset of `dolist' where the VAR binding can be a `pcase' PATTERN. |
| 308 | More specifically, this is just a shorthand for the following combination | ||
| 309 | of `dolist' and `pcase-let': | ||
| 310 | |||
| 311 | (dolist (x LIST) (pcase-let ((PATTERN x)) BODY...)) | ||
| 306 | \n(fn (PATTERN LIST) BODY...)" | 312 | \n(fn (PATTERN LIST) BODY...)" |
| 307 | (declare (indent 1) (debug ((pcase-PAT form) body))) | 313 | (declare (indent 1) (debug ((pcase-PAT form) body))) |
| 308 | (if (pcase--trivial-upat-p (car spec)) | 314 | (if (pcase--trivial-upat-p (car spec)) |