Martin S, thanks for the report. I apologize for not getting to this
earlier, but I don't know all that much about the byte compiler yet.
And I didn't want to waste Martin Buchholz's time, although he's the
obvious consultant (and it turns out that he probably made the
relevant change); he's on leave from the project at the moment.
>>>> "Martin" == Martin Stjernholm
Martin> Consider an elisp file containing this:
(defvar x (cl-macroexpand-all '(eval-when-compile
Martin> If this is byte compiled in XEmacs 21.4.6, the error
Martin> "evaluated" is signalled inside the byte compiler. It
Martin> turns out that the content of the `eval-when-compile' is
Martin> evaluated during the `cl-macroexpand-all' call. I did not
Martin> expect `error' to be evaluated at that point since it's a
Martin> function and not a macro.
Martin> This is a regression from (at least) XEmacs 20.4 and
Martin> 19.16, where x is simply assigned the quoted value (error
Martin> "evaluated") at compile time. FSF Emacs also works that
As does XEmacs 21.1. This looks like it's due to a change by Martin
2000-11-17 Martin Buchholz <martin(a)xemacs.org>
* bytecomp.el (byte-compile-eval): New.
(byte-compile-initial-macro-environment): Use byte-compile-eval.
Keeps this promise made in Lispref:
"If a file being compiled contains a `defmacro' form, the macro is
defined temporarily for the rest of the compilation of that file."
I've tried putting the call to byte-compile-top-level back in (see
partial diff 21.4 vs 21.1 below); that doesn't help. Changing
byte-compile-eval back to eval does help. Martin B, do you have any
idea what's going on here?
Also, I don't understand what byte-compile-eval is supposed to protect
against; I can't find anything---except the initialization and a
couple places that bind byte-compile-macro-environment to nil---that
actually changes byte-compile-macro-environment. I'm adding Martin
S's test case to the regression suite; do you have one that exercises
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/bytecomp.el,v
retrieving revision 1.10
retrieving revision 18.104.22.168
diff -u -r1.10 -r22.214.171.124
--- lisp/bytecomp.el 17 Nov 2000 03:21:22 -0000 1.10
+++ lisp/bytecomp.el 25 Jul 2001 07:44:22 -0000 126.96.36.199
＠＠ -443,16 +443,33 ＠＠
+;;; A form of eval that includes the currently defined macro definitions.
+;;; This helps implement the promise made in the Lispref:
+;;; "If a file being compiled contains a `defmacro' form, the macro is
+;;; defined temporarily for the rest of the compilation of that file."
+(defun byte-compile-eval (form)
+ (let ((save-macro-environment nil))
+ (loop for (sym . def) in byte-compile-macro-environment do
+ (if (fboundp sym) (cons sym (symbol-function sym)) sym)
+ (fset sym (cons 'macro def))
+ finally return (eval form))
+ (dolist (elt save-macro-environment)
+ (if (symbolp elt)
+ (fmakunbound elt)
+ (fset (car elt) (cdr elt)))))))
- '((byte-compiler-options . (lambda (&rest forms)
- (apply 'byte-compiler-options-handler forms)))
- (eval-when-compile . (lambda (&rest body)
- (list 'quote (eval (byte-compile-top-level
- (cons 'progn body))))))
- (eval-and-compile . (lambda (&rest body)
- (eval (cons 'progn body))
- (cons 'progn body)))))
+ '((byte-compiler-options . (lambda (&rest forms)
+ (apply 'byte-compiler-options-handler forms)))
+ (eval-when-compile . (lambda (&rest body)
+ (list 'quote (byte-compile-eval (cons 'progn body)))))
+ (eval-and-compile . (lambda (&rest body)
+ (byte-compile-eval (cons 'progn body))
+ (cons 'progn body))))
"The default macro-environment passed to macroexpand by the compiler.
Placing a macro here will cause a macro to have different semantics when
expanded by the compiler as when expanded by the interpreter.")
Institute of Policy and Planning Sciences http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
My nostalgia for Icon makes me forget about any of the bad things. I don't
have much nostalgia for Perl, so its faults I remember. Scott Gilbert c.l.py