emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] fix/bug-31311-pcase-doc 0133e9a 6/8: add some @group; rewo


From: Thien-Thi Nguyen
Subject: [Emacs-diffs] fix/bug-31311-pcase-doc 0133e9a 6/8: add some @group; rework example to use fewer lines
Date: Sat, 19 May 2018 07:39:37 -0400 (EDT)

branch: fix/bug-31311-pcase-doc
commit 0133e9a541ecddbc5bfe5ee8cffaa1a61585db56
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>

    add some @group; rework example to use fewer lines
---
 doc/lispref/control.texi | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 8b8bdb4..86f6365 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -490,17 +490,23 @@ has over @code{case}
 (@pxref{Conditionals,,,cl,Common Lisp Extensions}).
 
 @example
address@hidden
 (pcase (get-return-code x)
   ;; string
   ((and (pred stringp) msg)
    (message "%s" msg))
address@hidden group
address@hidden
   ;; symbol
   ('success       (message "Done!"))
   ('would-block   (message "Sorry, can't do it now"))
   ('read-only     (message "The shmliblick is read-only"))
   ('access-denied (message "You do not have the needed rights"))
address@hidden group
address@hidden
   ;; default
   (code           (message "Unknown return code %S" code)))
address@hidden group
 @end example
 
 @noindent
@@ -518,10 +524,12 @@ to the sub-patterns that follow (as well as to the body 
forms).
 For example, the following pattern matches single-digit integers.
 
 @example
address@hidden
 (and
   (pred integerp)
   n                     ; @r{bind @code{n} to @var{expval}}
   (guard (<= -9 n 9)))
address@hidden group
 @end example
 
 @noindent
@@ -667,31 +675,26 @@ On the other hand, B uses two separate symbols, @code{s1} 
and
 @code{s2}, both of which become independent bindings.
 
 @example
address@hidden
 (defun grok (object)
   (pcase object
     ((and (pred consp)        ; seqpat A
           (app car st)        ; first mention: st
           (app cdr st))       ; second mention: st
      (list 'eq st))
address@hidden group
address@hidden
     ((and (pred consp)        ; seqpat B
           (app car s1)        ; first mention: s1
           (app cdr s2))       ; first mention: s2
      (list 'not-eq s1 s2))))
-
address@hidden
-(grok (let ((s "yow!"))
-        (cons s s)))
address@hidden (eq "yow!")
address@hidden group
-
address@hidden
-(grok (cons "yow!" "yow!"))
address@hidden (not-eq "yow!" "yow!")
 @end group
 
 @group
-(grok '(4 2))
address@hidden (not-eq 4 (2))
+(let ((s "yow!"))
+  (grok (cons s s)))      @result{} (eq "yow!")
+(grok (cons "yo!" "yo!")) @result{} (not-eq "yo!" "yo!")
+(grok '(4 2))             @result{} (not-eq 4 (2))
 @end group
 @end example
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]