Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
5390:593d9f73a7e8 | 5391:f9dc75bdbdc4 |
---|---|
619 | 619 |
620 ;;;###autoload | 620 ;;;###autoload |
621 (defmacro load-time-value (form &optional read-only) | 621 (defmacro load-time-value (form &optional read-only) |
622 "Like `progn', but evaluates the body at load time. | 622 "Like `progn', but evaluates the body at load time. |
623 The result of the body appears to the compiler as a quoted constant." | 623 The result of the body appears to the compiler as a quoted constant." |
624 (if (cl-compiling-file) | 624 (let ((gensym (gensym))) |
625 (let* ((temp (gentemp "--cl-load-time--")) | 625 ;; The body of this macro really should be (cons 'progn form), with the |
626 (set (list 'set (list 'quote temp) form))) | 626 ;; hairier stuff in a shadowed version in |
627 (if (and (fboundp 'byte-compile-file-form-defmumble) | 627 ;; byte-compile-initial-macro-environment. That doesn't work because |
628 (boundp 'this-kind) (boundp 'that-one)) | 628 ;; cl-macs.el doesn't respect byte-compile-macro-environment, which is |
629 (fset 'byte-compile-file-form | 629 ;; something we should change. |
630 (list 'lambda '(form) | 630 (put gensym 'cl-load-time-value-form form) |
631 (list 'fset '(quote byte-compile-file-form) | 631 (set gensym (eval form)) |
632 (list 'quote | 632 `(symbol-value ',gensym))) |
633 (symbol-function 'byte-compile-file-form))) | |
634 (list 'byte-compile-file-form (list 'quote set)) | |
635 '(byte-compile-file-form form))) | |
636 ;; XEmacs change | |
637 (print set (symbol-value ;;'outbuffer | |
638 'byte-compile-output-buffer | |
639 ))) | |
640 (list 'symbol-value (list 'quote temp))) | |
641 (list 'quote (eval form)))) | |
642 | |
643 | 633 |
644 ;;; Conditional control structures. | 634 ;;; Conditional control structures. |
645 | 635 |
646 ;;;###autoload | 636 ;;;###autoload |
647 (defmacro case (expr &rest clauses) | 637 (defmacro case (expr &rest clauses) |