[COMPILE] Warn at compile time, error at runtime, with (quote X Y), (function X Y).

Aidan Kehoe kehoea at parhasard.net
Thu Sep 16 09:11:37 EDT 2010


APPROVE COMMIT

NOTE: This patch has been committed.

# HG changeset patch
# User Aidan Kehoe <kehoea at parhasard.net>
# Date 1284642644 -3600
# Node ID 5663ae9a89895c1f42a18d6e3d3bf08f6a5fdc55
# Parent  0d43872986b6e54e666d9e4f30da5a2c9c6ce423
Warn at compile time, error at runtime, with (quote X Y), (function X Y).

lisp/ChangeLog addition:

2010-09-16  Aidan Kehoe  <kehoea at parhasard.net>

	* bytecomp.el (byte-compile-function-form, byte-compile-quote)
	(byte-compile-quote-form):
	Warn at compile time, and error at runtime, if a (quote ...) or a
	(function ...) form attempts to quote more than one object.

src/ChangeLog addition:

2010-09-16  Aidan Kehoe  <kehoea at parhasard.net>

	* eval.c (Ffunction, Fquote):
	Add argument information in the arguments: () format for these two
	special operators.

diff -r 0d43872986b6 -r 5663ae9a8989 lisp/ChangeLog
--- a/lisp/ChangeLog	Thu Sep 16 13:51:49 2010 +0100
+++ b/lisp/ChangeLog	Thu Sep 16 14:10:44 2010 +0100
@@ -1,3 +1,10 @@
+2010-09-16  Aidan Kehoe  <kehoea at parhasard.net>
+
+	* bytecomp.el (byte-compile-function-form, byte-compile-quote)
+	(byte-compile-quote-form):
+	Warn at compile time, and error at runtime, if a (quote ...) or a
+	(function ...) form attempts to quote more than one object.
+
 2010-09-16  Aidan Kehoe  <kehoea at parhasard.net>
 
 	* byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc
diff -r 0d43872986b6 -r 5663ae9a8989 lisp/bytecomp.el
--- a/lisp/bytecomp.el	Thu Sep 16 13:51:49 2010 +0100
+++ b/lisp/bytecomp.el	Thu Sep 16 14:10:44 2010 +0100
@@ -3581,10 +3581,13 @@
 ;; and (funcall (function foo)) will lose with autoloads.
 
 (defun byte-compile-function-form (form)
-  (byte-compile-constant
-   (cond ((symbolp (nth 1 form))
-	  (nth 1 form))
-	 ((byte-compile-lambda (nth 1 form))))))
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(function ,(length (cdr form)))))
+    (byte-compile-constant
+     (cond ((symbolp (nth 1 form))
+            (nth 1 form))
+           ((byte-compile-lambda (nth 1 form)))))))
 
 (defun byte-compile-insert (form)
   (cond ((null (cdr form))
@@ -3714,11 +3717,16 @@
 
 
 (defun byte-compile-quote (form)
-  (byte-compile-constant (car (cdr form))))
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
+    (byte-compile-constant (car (cdr form)))))
 
 (defun byte-compile-quote-form (form)
-  (byte-compile-constant (byte-compile-top-level (nth 1 form))))
-
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
+    (byte-compile-constant (byte-compile-top-level (nth 1 form)))))
 
 ;;; control structures
 
diff -r 0d43872986b6 -r 5663ae9a8989 src/ChangeLog
--- a/src/ChangeLog	Thu Sep 16 13:51:49 2010 +0100
+++ b/src/ChangeLog	Thu Sep 16 14:10:44 2010 +0100
@@ -1,3 +1,9 @@
+2010-09-16  Aidan Kehoe  <kehoea at parhasard.net>
+
+	* eval.c (Ffunction, Fquote):
+	Add argument information in the arguments: () format for these two
+	special operators.
+
 2010-09-07  Aidan Kehoe  <kehoea at parhasard.net>
 
 	* fns.c (Freplace): 
diff -r 0d43872986b6 -r 5663ae9a8989 src/eval.c
--- a/src/eval.c	Thu Sep 16 13:51:49 2010 +0100
+++ b/src/eval.c	Thu Sep 16 14:10:44 2010 +0100
@@ -1270,6 +1270,8 @@
 object preceded by `''. Thus, `'x' is equivalent to `(quote x)', in all
 contexts.  A print function may use either.  Internally the expression is
 represented as `(quote x)').
+
+arguments: (OBJECT)
 */
        (args))
 {
@@ -1350,6 +1352,8 @@
 object preceded by `#''. Thus, #'x is equivalent to (function x), in all
 contexts.  A print function may use either.  Internally the expression is
 represented as `(function x)').
+
+arguments: (SYMBOL-OR-LAMBDA)
 */
        (args))
 {


-- 
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
  -- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research



More information about the XEmacs-Patches mailing list