[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/bug-31311-pcase-doc d2a0b3b 2/8: refine side-effect ex
From: |
Thien-Thi Nguyen |
Subject: |
[Emacs-diffs] fix/bug-31311-pcase-doc d2a0b3b 2/8: refine side-effect example |
Date: |
Wed, 16 May 2018 14:49:55 -0400 (EDT) |
branch: fix/bug-31311-pcase-doc
commit d2a0b3b4935a0a3733a688ac736d999ec7567016
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>
refine side-effect example
- rename funcs: ‘s/OK/CLEAN/g’; ‘s/WRONG/MAYBE/g’
- add "WRONG!" comment to MAYBE's ‘(yes 9)’ result
---
doc/lispref/control.texi | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index d692f2d..f1ec0da 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -655,30 +655,30 @@ Both use @code{and}, @var{symbol} and @code{guard}:
@example
@group
-(defun square-double-digit-p/OK (integer)
+(defun square-double-digit-p/CLEAN (integer)
(pcase (* integer integer)
((and n (guard (< 9 n 100))) (list 'yes n))
(sorry (list 'no sorry))))
-(square-double-digit-p/OK 9) @result{} (yes 81)
-(square-double-digit-p/OK 3) @result{} (no 9)
+(square-double-digit-p/CLEAN 9) @result{} (yes 81)
+(square-double-digit-p/CLEAN 3) @result{} (no 9)
@end group
@group
-(defun square-double-digit-p/WRONG (integer)
+(defun square-double-digit-p/MAYBE (integer)
(pcase (* integer integer)
((and n (guard (< 9 (incf n) 100))) (list 'yes n))
(sorry (list 'no sorry))))
-(square-double-digit-p/WRONG 9) @result{} (yes 81)
-(square-double-digit-p/WRONG 3) @result{} (yes 9)
+(square-double-digit-p/MAYBE 9) @result{} (yes 81)
+(square-double-digit-p/MAYBE 3) @result{} (yes 9) ; @r{WRONG!}
@end group
@end example
@noindent
The difference is in @var{boolean-expression} in @code{guard}:
address@hidden references @code{n} simply and directly,
-while @code{WRONG} references @code{n} with a side-effect,
address@hidden references @code{n} simply and directly,
+while @code{MAYBE} references @code{n} with a side-effect,
in the expression @code{(incf n)}.
When @code{integer} is 3, here's what happens:
@@ -706,7 +706,7 @@ control passes to that clause's body forms.
@noindent
Aside from the mathematical incorrectness of asserting that 9 is a
-double-digit integer, there is another problem with @code{WRONG}.
+double-digit integer, there is another problem with @code{MAYBE}.
The body form references @code{n} once more, yet we do not see
the updated value---10---at all. What happened to it?
- [Emacs-diffs] fix/bug-31311-pcase-doc updated (2db5695 -> 707c81f), Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc bdbe79a 1/8: minor clarifications, Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc 0f3563b 4/8: use @code instead of `docstring-style' quoting, Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc 4cf4faa 5/8: (docstring) ensure backquote is output first, Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc d2a0b3b 2/8: refine side-effect example,
Thien-Thi Nguyen <=
- [Emacs-diffs] fix/bug-31311-pcase-doc ba2e20e 3/8: say address@hidden instead of @code{t}, Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc 3f614b6 7/8: rewrite intro, Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc 877cf63 6/8: bifurcate "U-pattern", Thien-Thi Nguyen, 2018/05/16
- [Emacs-diffs] fix/bug-31311-pcase-doc 707c81f 8/8: don't quote "equality test"; use instead "the equality test", Thien-Thi Nguyen, 2018/05/16