diff lisp/cl-macs.el @ 5391:f9dc75bdbdc4

Implement #'load-time-value less hackishly, by modifying the byte compiler. 2011-04-02 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-output-preface): New. * bytecomp.el (byte-compile-output-file-form): * bytecomp.el (byte-compile-output-docform): * bytecomp.el (byte-compile-file-form): * bytecomp.el (byte-compile-file-form-defmumble): * bytecomp.el (symbol-value): * bytecomp.el (byte-compile-symbol-value): New. * cl-macs.el (load-time-value): No longer implement load-time-value by very hackishly redefining #'byte-compile-file-form-defmumble, instead make the appropriate changes in #'byte-compile-file-form-defmumble and #'byte-compile-file-form instead. We also add a specific byte-compile method for #'symbol-value, using the add-properties-to-a-gensym approach that worked for #'block and #'return-from.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 02 Apr 2011 16:13:20 +0100
parents 3889ef128488
children 97ac18bd1fa3 248176c74e6b
line wrap: on
line diff
--- a/lisp/cl-macs.el	Sat Apr 02 17:04:38 2011 +0900
+++ b/lisp/cl-macs.el	Sat Apr 02 16:13:20 2011 +0100
@@ -621,25 +621,15 @@
 (defmacro load-time-value (form &optional read-only)
   "Like `progn', but evaluates the body at load time.
 The result of the body appears to the compiler as a quoted constant."
-  (if (cl-compiling-file)
-      (let* ((temp (gentemp "--cl-load-time--"))
-	     (set (list 'set (list 'quote temp) form)))
-	(if (and (fboundp 'byte-compile-file-form-defmumble)
-		 (boundp 'this-kind) (boundp 'that-one))
-	    (fset 'byte-compile-file-form
-		  (list 'lambda '(form)
-			(list 'fset '(quote byte-compile-file-form)
-			      (list 'quote
-				    (symbol-function 'byte-compile-file-form)))
-			(list 'byte-compile-file-form (list 'quote set))
-			'(byte-compile-file-form form)))
-	  ;; XEmacs change
-	  (print set (symbol-value ;;'outbuffer
-				   'byte-compile-output-buffer
-				   )))
-	(list 'symbol-value (list 'quote temp)))
-    (list 'quote (eval form))))
-
+  (let ((gensym (gensym)))
+    ;; The body of this macro really should be (cons 'progn form), with the
+    ;; hairier stuff in a shadowed version in
+    ;; byte-compile-initial-macro-environment. That doesn't work because
+    ;; cl-macs.el doesn't respect byte-compile-macro-environment, which is
+    ;; something we should change.
+    (put gensym 'cl-load-time-value-form form)
+    (set gensym (eval form))
+    `(symbol-value ',gensym)))
 
 ;;; Conditional control structures.