[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/bug-31311-pcase-doc bd79b06 15/18: add anchor/heading
From: |
Thien-Thi Nguyen |
Subject: |
[Emacs-diffs] fix/bug-31311-pcase-doc bd79b06 15/18: add anchor/heading to examples; fix typo |
Date: |
Tue, 15 May 2018 05:45:54 -0400 (EDT) |
branch: fix/bug-31311-pcase-doc
commit bd79b060bacbd4617670d388f27277ab92b6655c
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>
add anchor/heading to examples; fix typo
---
doc/lispref/control.texi | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 98e917f..4787310 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -419,6 +419,9 @@ should all bind the same symbols.
Matches if all the argument U-patterns match.
@end table
address@hidden
address@hidden Example 1: Using @code{and}
+
A common idiom is to write a pattern starting with @code{and},
with one or more @var{symbol} sub-patterns providing bindings
to the sub-patterns that follow (as well as to the body forms).
@@ -441,6 +444,9 @@ Lastly, @code{guard} matches if the boolean expression
evaluates to address@hidden
If all these sub-patterns match, @code{and} matches.
address@hidden
address@hidden Example 2: Reformulation with @code{pcase}
+
Here is another example that shows how to reformulate a simple
matching task from its traditional implementation
(function @code{grok/traditional}) to one using
@@ -499,8 +505,7 @@ The pattern is @code{or}, which tries to match in turn its
argument
sub-patterns, first @code{and} (lines 2-7), then @code{let} (line 8),
until one of them succeeds.
address@hidden TODO: add anchor (and maybe heading) above; add pxref here
-As in the previous example,
+As in the previous example (@pxref{pcase-example-1,,Example 1}),
@code{and} begins with a @code{pred} sub-pattern to ensure
the following sub-patterns work with an object of the correct
type (string, in this case). If @address@hidden(stringp @var{expval})}}
@@ -510,7 +515,7 @@ The next @code{pred} (lines 4-5) evaluates
@address@hidden(string-match RX @var{expval})}}
and matches if the result is address@hidden, which means
that @var{expval} has the desired form: @code{key:NUMBER}.
-Again, failing this, @var{pred} fails and @code{and}, too.
+Again, failing this, @code{pred} fails and @code{and}, too.
Lastly (in this series of @code{and} sub-patterns), @code{app}
evaluates @address@hidden(match-string 1 @var{expval})}}
- [Emacs-diffs] fix/bug-31311-pcase-doc b3fb63e 05/18: zonk "Depending on the pattern" para (superseded by SYMBOL expansion), (continued)
- [Emacs-diffs] fix/bug-31311-pcase-doc b3fb63e 05/18: zonk "Depending on the pattern" para (superseded by SYMBOL expansion), Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 15378c3 08/18: do ‘s/predicate function/predicate/’, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc f2610c6 11/18: for ‘app’, refine comparison w/ ‘pred’, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc abf7e6a 03/18: zonk "side-effecting" Issue comment lines, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc c0f0f18 07/18: zonk later address@hidden introduction (superseded), Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 0f1c170 06/18: settle on address@hidden pcase’ text, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc dc4b413 09/18: do ‘s/predfun/function/g’, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 5e2eeee 17/18: transform ‘get-return-code’ example, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc e276ce7 13/18: transform ‘guard’ example, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc ff41db6 12/18: (docstring) quote ‘pcase’ in QPAT docstring, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc bd79b06 15/18: add anchor/heading to examples; fix typo,
Thien-Thi Nguyen <=
- [Emacs-diffs] fix/bug-31311-pcase-doc d5dfe0e 02/18: expand on SYMBOL, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 0dffb69 10/18: (docstring) do s/predicate function/predicate/g, s/specified/formed/g, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 4ede733 16/18: refine example header, grouping, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 484c3ae 18/18: add xref to ‘(cl) Conditionals’, Thien-Thi Nguyen, 2018/05/15
- [Emacs-diffs] fix/bug-31311-pcase-doc 279d548 14/18: transform ‘let’ example, Thien-Thi Nguyen, 2018/05/15