[alexandria.git] updated branch master: c1644df beef up the README a bit

Nikodemus Siivola nsiivola at common-lisp.net
Wed Nov 2 16:38:46 UTC 2011


The branch master has been updated:
       via  c1644dfb6b0d8c74751ff080265e0e436e83c64b (commit)
       via  6fb9452b2bbd3867aa29bb0070d8919c4d1a572d (commit)
      from  268b6da4603d156cd22fedbfd5b8c5e67d2a394e (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 c1644dfb6b0d8c74751ff080265e0e436e83c64b
Author: Nikodemus Siivola <nikodemus at random-state.net>
Date:   Wed Nov 2 18:33:48 2011 +0200

    beef up the README a bit

commit 6fb9452b2bbd3867aa29bb0070d8919c4d1a572d
Author: James M. Lawrence <llmjjmll at gmail.com>
Date:   Wed Nov 2 18:25:13 2011 +0200

    fix bug in CURRY compiler-macro
    
      Multiple evaluation of the function argument, oops.

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

Summary of changes:
 README         |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 functions.lisp |   12 ++++++++----
 tests.lisp     |   22 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 6 deletions(-)

diff --git a/README b/README
index 930e7ec..8081c60 100644
--- a/README
+++ b/README
@@ -1,3 +1,52 @@
-Alexandria
+Alexandria is a collection of portable public domain utilities that
+meet the following constraints:
 
-A collection of portable public domain utilities for Common Lisp.
+ * Utilities, not extensions: Alexandria will not contain conceptual
+   extensions to Common Lisp, instead limiting itself to tools and
+   utilities that fit well within the framework of standard ANSI
+   Common Lisp. Test-frameworks, system definitions, logging
+   facilities, serialization layers, etc. are all outside the scope of
+   Alexandria as a library, though well within the scope of Alexandria
+   as a project.
+
+ * Conservative: Alexandria limits itself to what project members
+   consider conservative utilities. Alexandria does not and will not
+   include anaphoric constructs, loop-like binding macros, etc.
+
+ * Portable: Alexandria limits itself to portable parts of Common
+   Lisp. Even apparently conservative and usefull functions remain
+   outside the scope of Alexandria if they cannot be implemented
+   portably. Portability is here defined as portable within a
+   conforming implementation: implementation bugs are not considered
+   portability issues.
+
+Homepage:
+
+  http://common-lisp.net/project/alexandria/
+
+Mailing lists:
+
+  http://lists.common-lisp.net/mailman/listinfo/alexandria-devel
+  http://lists.common-lisp.net/mailman/listinfo/alexandria-cvs
+
+Repository:
+
+  git://common-lisp.net/projects/alexandria/alexandria.git
+
+Documentation:
+
+  http://common-lisp.net/project/alexandria/draft/alexandria.html
+
+  (To build docs locally: cd doc && make html pdf info)
+
+Patches:
+
+  Patches are always welcome! Please send them to the mailing list as
+  attachments, generated by "git format-patch -1".
+
+  Patches should include a commit message that explains what's being
+  done and /why/, and when fixing a bug or adding a feature you should
+  also include a test-case.
+
+  Be adviced though that right now new features are unlikely to be
+  accepted until 1.0 is officially out of the door.
diff --git a/functions.lisp b/functions.lisp
index 15032be..f703a99 100644
--- a/functions.lisp
+++ b/functions.lisp
@@ -1,6 +1,8 @@
 (in-package :alexandria)
 
-(declaim (inline ensure-function))	; to propagate return type.
+;;; To propagate return type and allow the compiler to eliminate the IF when
+;;; it is known if the argument is function or not.
+(declaim (inline ensure-function))
 
 (declaim (ftype (function (t) (values function &optional))
                 ensure-function))
@@ -120,11 +122,13 @@ it is called with to FUNCTION."
       (multiple-value-call fn (values-list arguments) (values-list more)))))
 
 (define-compiler-macro curry (function &rest arguments)
-  (let ((curries (make-gensym-list (length arguments) "CURRY")))
-    `(let ,(mapcar #'list curries arguments)
+  (let ((curries (make-gensym-list (length arguments) "CURRY"))
+        (fun (gensym "FUN")))
+    `(let ((,fun (ensure-function ,function))
+           ,@(mapcar #'list curries arguments))
        (declare (optimize (speed 3) (safety 1) (debug 1)))
        (lambda (&rest more)
-         (apply ,function , at curries more)))))
+         (apply ,fun , at curries more)))))
 
 (defun rcurry (function &rest arguments)
   "Returns a function that applies the arguments it is called
diff --git a/tests.lisp b/tests.lisp
index a4a8e55..20caf8a 100644
--- a/tests.lisp
+++ b/tests.lisp
@@ -508,11 +508,33 @@
         (funcall fun 2)))
   4)
 
+(deftest curry.4
+    (let* ((x 1)
+           (curried (curry (progn
+                             (incf x)
+                             (lambda (y z) (* x y z)))
+                           3)))
+      (list (funcall curried 7)
+            (funcall curried 7)
+            x))
+  (42 42 2))
+
 (deftest rcurry.1
     (let ((r (rcurry '/ 2)))
       (funcall r 8))
   4)
 
+(deftest rcurry.2
+    (let* ((x 1)
+           (curried (rcurry (progn
+                              (incf x)
+                              (lambda (y z) (* x y z)))
+                            3)))
+      (list (funcall curried 7)
+            (funcall curried 7)
+            x))
+  (42 42 2))
+
 (deftest named-lambda.1
     (let ((fac (named-lambda fac (x)
                  (if (> x 1)
-- 
Alexandria hooks/post-receive




More information about the alexandria-cvs mailing list