[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r115729: Fix missing arg in pcase example.
From: |
Tassilo Horn |
Subject: |
[Emacs-diffs] trunk r115729: Fix missing arg in pcase example. |
Date: |
Tue, 24 Dec 2013 15:31:04 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 115729
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/16238
committer: Tassilo Horn <address@hidden>
branch nick: trunk
timestamp: Tue 2013-12-24 16:30:59 +0100
message:
Fix missing arg in pcase example.
* doc/lispref/control.texi (Pattern matching case statement): Fix missing
argument in simple expression language sample. Add
some sample programs written in that language. Mention that
`pcase' requires lexical binding.
modified:
doc/lispref/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-6155
doc/lispref/control.texi
control.texi-20091113204419-o5vbwnq5f7feedwu-6169
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog 2013-12-23 11:27:29 +0000
+++ b/doc/lispref/ChangeLog 2013-12-24 15:30:59 +0000
@@ -1,3 +1,10 @@
+2013-12-24 Tassilo Horn <address@hidden>
+
+ * control.texi (Pattern matching case statement): Fix missing
+ argument in simple expression language sample (Bug#16238). Add
+ some sample programs written in that language. Mention that
+ `pcase' requires lexical binding.
+
2013-12-23 Xue Fuqiao <address@hidden>
* eval.texi (Special Forms): Document `special-form-p'.
=== modified file 'doc/lispref/control.texi'
--- a/doc/lispref/control.texi 2013-10-09 17:17:20 +0000
+++ b/doc/lispref/control.texi 2013-12-24 15:30:59 +0000
@@ -328,7 +328,7 @@
(defun evaluate (exp env)
(pcase exp
(`(add ,x ,y) (+ (evaluate x env) (evaluate y env)))
- (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env)))
+ (`(call ,fun ,arg) (funcall (evaluate fun env) (evaluate arg env)))
(`(fn ,arg ,body) (lambda (val)
(evaluate body (cons (cons arg val) env))))
((pred numberp) exp)
@@ -342,6 +342,19 @@
@code{(pred numberp)} is a pattern that simply checks that @code{exp}
is a number, and @code{_} is the catch-all pattern that matches anything.
+Here are some sample programs including their evaluation results:
+
address@hidden
+(evaluate '(add 1 2) nil) ;=> 3
+(evaluate '(add x y) '((x . 1) (y . 2))) ;=> 3
+(evaluate '(call (fn x (add 1 x)) 2) nil) ;=> 3
+(evaluate '(sub 1 2) nil) ;=> (error "Unknown expression (sub
1 2)")
address@hidden example
+
+Note that (parts of) @code{pcase} only work as expected with lexical
+binding, so lisp files using @code{pcase} should have enable it
+(@pxref{Using Lexical Binding}, for how to enable lexical binding).
+
There are two kinds of patterns involved in @code{pcase}, called
@emph{U-patterns} and @emph{Q-patterns}. The @var{upattern} mentioned above
are U-patterns and can take the following forms:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r115729: Fix missing arg in pcase example.,
Tassilo Horn <=