commit: Add an assertion about argument order to #'apply-partially compiler macro

Aidan Kehoe kehoea at parhasard.net
Wed Aug 24 06:22:54 EDT 2011


changeset:   5553:62edcc6a11ec
parent:      5550:b908c7265a2b
user:        Aidan Kehoe <kehoea at parhasard.net>
date:        Wed Aug 24 11:06:41 2011 +0100
files:       lisp/ChangeLog lisp/cl-macs.el tests/ChangeLog tests/automated/lisp-tests.el
description:
Add an assertion about argument order to #'apply-partially compiler macro

lisp/ChangeLog addition:

2011-08-24  Aidan Kehoe  <kehoea at parhasard.net>

	* cl-macs.el (apply-partially):
	Add an assertion to this compiler macro, requiring that the order
	of the placeholders corresponding to the arguments in the
	constants vector of the constructed compiled function be the same
	as the order of the arguments to #'apply-partially.

tests/ChangeLog addition:

2011-08-24  Aidan Kehoe  <kehoea at parhasard.net>

	* automated/lisp-tests.el:
	Add a test of apply partially that depends on the relative order
	of its arguments.


diff -r b908c7265a2b -r 62edcc6a11ec lisp/ChangeLog
--- a/lisp/ChangeLog	Fri Aug 12 16:02:30 2011 +0100
+++ b/lisp/ChangeLog	Wed Aug 24 11:06:41 2011 +0100
@@ -1,3 +1,11 @@
+2011-08-24  Aidan Kehoe  <kehoea at parhasard.net>
+
+	* cl-macs.el (apply-partially):
+	Add an assertion to this compiler macro, requiring that the order
+	of the placeholders corresponding to the arguments in the
+	constants vector of the constructed compiled function be the same
+	as the order of the arguments to #'apply-partially.
+
 2011-08-12  Aidan Kehoe  <kehoea at parhasard.net>
 
 	* cl-macs.el:
diff -r b908c7265a2b -r 62edcc6a11ec lisp/cl-macs.el
--- a/lisp/cl-macs.el	Fri Aug 12 16:02:30 2011 +0100
+++ b/lisp/cl-macs.el	Wed Aug 24 11:06:41 2011 +0100
@@ -3519,6 +3519,13 @@
       (let* ((placeholders (mapcar 'quote-maybe (mapcar 'gensym args)))
              (compiled (byte-compile-sexp
                         `#'(lambda (&rest args) (apply , at placeholders args)))))
+        (assert (equal (intersection
+                        (mapcar 'quote-maybe (compiled-function-constants
+                                              compiled))
+                        placeholders :test 'equal :stable t)
+                       placeholders)
+                t "This macro requires that the relative order is the same\
+in the constants vector and in the arguments")
         `(make-byte-code
           ',(compiled-function-arglist compiled)
           ,(compiled-function-instructions compiled)
diff -r b908c7265a2b -r 62edcc6a11ec tests/ChangeLog
--- a/tests/ChangeLog	Fri Aug 12 16:02:30 2011 +0100
+++ b/tests/ChangeLog	Wed Aug 24 11:06:41 2011 +0100
@@ -1,3 +1,9 @@
+2011-08-24  Aidan Kehoe  <kehoea at parhasard.net>
+
+	* automated/lisp-tests.el:
+	Add a test of apply partially that depends on the relative order
+	of its arguments.
+
 2011-08-12  Aidan Kehoe  <kehoea at parhasard.net>
 
 	* automated/lisp-tests.el:
diff -r b908c7265a2b -r 62edcc6a11ec tests/automated/lisp-tests.el
--- a/tests/automated/lisp-tests.el	Fri Aug 12 16:02:30 2011 +0100
+++ b/tests/automated/lisp-tests.el	Wed Aug 24 11:06:41 2011 +0100
@@ -2929,10 +2929,13 @@
 ;; Basic tests of #'apply-partially.
 (let* ((four 4)
        (times-four (apply-partially '* four))
-       (plus-twelve (apply-partially '+ 6 (* 3 2))))
+       (plus-twelve (apply-partially '+ 6 (* 3 2)))
+       (construct-list (apply-partially 'list (incf four) (incf four)
+                                        (incf four))))
   (Assert (eql (funcall times-four 6) 24))
   (Assert (eql (funcall times-four 4 4) 64))
   (Assert (eql (funcall plus-twelve (funcall times-four 4) 4 4) 36))
-  (Check-Error wrong-number-of-arguments (apply-partially)))
+  (Check-Error wrong-number-of-arguments (apply-partially))
+  (Assert (equal (funcall construct-list) '(5 6 7))))
 
 ;;; end of lisp-tests.el



More information about the XEmacs-Patches mailing list