[alexandria.git] updated branch master: 4907281... better docstring for MULTIPLE-VALUE-PROG2, a few more tests

Nikodemus Siivola nsiivola at common-lisp.net
Mon Apr 5 16:53:37 UTC 2010


The branch master has been updated:
       via  4907281d91c17056a4ddfdc46cec512ed2859f0f (commit)
      from  043f9804cbc3b91964b6cbdb72c1cdd1f300b3ad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4907281d91c17056a4ddfdc46cec512ed2859f0f
Author: Nikodemus Siivola <nikodemus at random-state.net>
Date:   Mon Apr 5 19:52:54 2010 +0300

    better docstring for MULTIPLE-VALUE-PROG2, a few more tests

-----------------------------------------------------------------------

Summary of changes:
 control-flow.lisp |   10 +++++-----
 package.lisp      |    9 ++++++---
 tests.lisp        |   33 +++++++++++++++++++++++++--------
 3 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/control-flow.lisp b/control-flow.lisp
index 0aafb2a..f262443 100644
--- a/control-flow.lisp
+++ b/control-flow.lisp
@@ -68,7 +68,7 @@ returns the values of DEFAULT if no keys match."
                ,(expand possibilities 0 random-number)))))))
 
 (defmacro xor (&rest datums)
-  "Evaluates its argument one at a time, from left to right. If more then one
+  "Evaluates its arguments one at a time, from left to right. If more then one
 argument evaluates to a true value no further DATUMS are evaluated, and NIL is
 returned as both primary and secondary value. If exactly one argument
 evaluates to true, its value is returned as the primary value after all the
@@ -100,7 +100,7 @@ NIL."
                   `(nth-value-or ,nth-value ,@(rest forms))
                   nil))))))
 
-(defmacro multiple-value-prog2 (first-form second-form &body body)
-  "Like CL:MULTIPLE-VALUE-PROG1, except it saves the values of the
-second form."
-  `(progn ,first-form (multiple-value-prog1 ,second-form , at body)))
+(defmacro multiple-value-prog2 (first-form second-form &body forms)
+  "Evaluates FIRST-FORM, then SECOND-FORM, and then FORMS. Yields as its value
+all the value returned by SECOND-FORM."
+  `(progn ,first-form (multiple-value-prog1 ,second-form , at forms)))
diff --git a/package.lisp b/package.lisp
index c7f9bf1..b5ce17b 100644
--- a/package.lisp
+++ b/package.lisp
@@ -13,16 +13,19 @@
    ;; REVIEW IN PROGRESS
    ;;
    ;; Control flow
+   ;;
+   ;; -- no clear consensus yet --
    #:cswitch
    #:eswitch
    #:switch
+   ;; -- problem free? --
    #:multiple-value-prog2
-   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-   ;; REVIEW PENDING
-   ;;
    #:nth-value-or
    #:whichever
    #:xor
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   ;; REVIEW PENDING
+   ;;
    ;; Definitions
    #:define-constant
    ;; Hash tables
diff --git a/tests.lisp b/tests.lisp
index e2904cc..c139568 100644
--- a/tests.lisp
+++ b/tests.lisp
@@ -138,6 +138,21 @@
       (13.0 :oops))
   :yay)
 
+(deftest multiple-value-prog2.1
+    (multiple-value-prog2
+        (values 1 1 1)
+        (values 2 20 200)
+      (values 3 3 3))
+  2 20 200)
+
+(deftest nth-value-or.1
+    (multiple-value-bind (a b c)
+        (nth-value-or 1
+                      (values 1 nil 1)
+                      (values 2 2 2))
+      (= a b c 2))
+  t)
+
 (deftest whichever.1
     (let ((x (whichever 1 2 3)))
       (and (member x '(1 2 3)) t))
@@ -156,6 +171,16 @@
   1
   t)
 
+(deftest xor.2
+    (xor nil nil 1 2)
+  nil
+  nil)
+
+(deftest xor.3
+    (xor nil nil nil)
+  nil
+  t)
+
 ;;;; Definitions
 
 (deftest define-constant.1
@@ -1677,14 +1702,6 @@
         :type-error))
   :type-error)
 
-(deftest nth-value-or.1
-    (multiple-value-bind (a b c)
-        (nth-value-or 1
-                      (values 1 nil 1)
-                      (values 2 2 2))
-      (= a b c 2))
-  t)
-
 (deftest doplist.1
     (let (keys values)
       (doplist (k v '(a 1 b 2 c 3) (values t (reverse keys) (reverse values) k v))
-- 
Alexandria hooks/post-receive




More information about the alexandria-cvs mailing list