[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/bug-31311-pcase-doc e0cda90 7/9: rework ‘evaluate’ ex
From: |
Thien-Thi Nguyen |
Subject: |
[Emacs-diffs] fix/bug-31311-pcase-doc e0cda90 7/9: rework ‘evaluate’ explanation |
Date: |
Thu, 17 May 2018 06:41:58 -0400 (EDT) |
branch: fix/bug-31311-pcase-doc
commit e0cda90b943ec2cd8d9703d625c2b190d1141515
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>
rework ‘evaluate’ explanation
- split into two paras
- start each para by naming the kind of pattern
- 1st: backquote-style patterns
- 2nd: core patterns
- (1st para) use "clause" for ‘call’, ‘fn’
- replace "pattern checks/matches and DOES-EVALUATION" w/
"pattern checks/matches; body DOES-EVALUATION"
- (2nd para) reword to use "match"
---
doc/lispref/control.texi | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 5f9aa03..df1d516 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -852,15 +852,22 @@ requires lexical binding, @pxref{Lexical Binding}):
@end example
@noindent
-Here @code{`(add ,x ,y)} is a pattern that checks that @code{form} is a
-three-element list starting with the literal symbol @code{add}, then
-extracts the second and third elements and binds them to the variables
address@hidden and @code{y}. Then it evaluates @code{x} and @code{y} and
-adds the results. The @code{call} and @code{fn} patterns similarly
-implement two flavors of function calls. @code{(pred numberp)} is a
-pattern that simply checks that @code{form} is a number and if so,
-evaluates it. @code{(pred symbolp)} matches symbols, and returns
-their association. Finally, @code{_} is the catch-all pattern that
+Here, the first three clauses use backquote-style patterns.
address@hidden(add ,x ,y)} is a pattern that checks that @code{form}
+is a three-element list starting with the literal symbol @code{add},
+then extracts the second and third elements and binds them
+to symbols @code{x} and @code{y}, respectively.
+The clause body evaluates @code{x} and @code{y} and adds the results.
+Similarly, the @code{call} clause implements a function call,
+and the @code{fn} clause implements an anonymous function definition.
+
+The remaining clauses use core patterns.
address@hidden(pred numberp)} matches if @code{form} is a number.
+On match, the body evaluates it.
address@hidden(pred symbolp)} matches if @code{form} is a symbol.
+On match, the body looks up the symbol in @code{env} and
+returns its association.
+Finally, @code{_} is the catch-all pattern that
matches anything, so it's suitable for reporting syntax errors.
Here are some sample programs in this small language, including their
- [Emacs-diffs] fix/bug-31311-pcase-doc updated (707c81f -> 2b1cc77), Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 71e4791 1/9: refill func ‘evaluate’ (less horiz, more vert), Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 1ecece4 3/9: say "Syntax error" in last ‘evaluate’ BODY-FORM, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 1b67f5f 2/9: do ‘s/exp/form/g’ for ‘evaluate’ + explanation, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 30a7b23 4/9: make para following ‘evaluate’ code a continuation, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc fbfabfb 6/9: add Issue comment; nfc, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 6abf621 5/9: add subsection ‘Extending @code{pcase}’, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc 070b784 8/9: use address@hidden in ‘evaluate’ small-program session, Thien-Thi Nguyen, 2018/05/17
- [Emacs-diffs] fix/bug-31311-pcase-doc e0cda90 7/9: rework ‘evaluate’ explanation,
Thien-Thi Nguyen <=
- [Emacs-diffs] fix/bug-31311-pcase-doc 2b1cc77 9/9: drop "Here, " from ‘evaluate’ explanation, Thien-Thi Nguyen, 2018/05/17