]> git.eshelyaron.com Git - emacs.git/commitdiff
Document pcase-lambda
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 8 Feb 2022 07:51:30 +0000 (08:51 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 8 Feb 2022 07:51:30 +0000 (08:51 +0100)
* doc/lispref/control.texi (Destructuring with pcase Patterns):
Document pcase-lambda (bug#20268).

doc/lispref/control.texi

index 634d46a785401f3d30dc33c9753b5ac18e17de38..2f1666ba7718d8ea82427932762b955a32c963fb 100644 (file)
@@ -1326,6 +1326,20 @@ Assign values to variables in a @code{setq} form, destructuring each
 @var{value} according to its respective @var{pattern}.
 @end defmac
 
+@defmac pcase-lambda lambda-list &rest body
+This is like @code{lambda}, but allows each argument to be a pattern.
+For instance, here's a simple function that takes a cons cell as the
+argument:
+
+@example
+(setq fun
+      (pcase-lambda (`(,key . ,val))
+        (vector key (* val 10))))
+(funcall fun '(foo . 2))
+    @result{} [foo 20]
+@end example
+@end defmac
+
 @node Iteration
 @section Iteration
 @cindex iteration