Helu, here is an unpolished test case to show the problem: -=-=- (defmacro frob-keyvals-string (string) (with-input-from-string (stream string) `(progn ,@(loop for key = (let ((x (read stream nil stream))) (if (eq x stream) (loop-finish) x)) for val = (read stream) for comment = (read stream) collect (list 'defvar key (list 'quote val) (string comment)))))) (frob-keyvals-string " foo fooval foocomment bar barval barcomment car carval carcomment") -=-=- When compiled with COMPILE-FILE in the 2010-04 snapshot, the above snippet appears to recompile the macro definition as many times as there are DEFVARs in the macro expansion. -- Madhu
On 4/24/10 3:42 AM, Madhu wrote:
Helu, here is an unpolished test case to show the problem:
-=-=- (defmacro frob-keyvals-string (string) (with-input-from-string (stream string) `(progn ,@(loop for key = (let ((x (read stream nil stream))) (if (eq x stream) (loop-finish) x)) for val = (read stream) for comment = (read stream) collect (list 'defvar key (list 'quote val) (string comment))))))
(frob-keyvals-string " foo fooval foocomment bar barval barcomment car carval carcomment")
-=-=-
When compiled with COMPILE-FILE in the 2010-04 snapshot, the above snippet appears to recompile the macro definition as many times as there are DEFVARs in the macro expansion.
I can confirm this. I thought it might be the fix for the bug that you reported about compiling a file with COMPILE in it. But that seems not the case. It looks like I might have to do a bit of time-traveling to isolate the problem. This might take a while... Ray
On 4/24/10 3:42 AM, Madhu wrote:
Helu, here is an unpolished test case to show the problem:
-=-=- (defmacro frob-keyvals-string (string) (with-input-from-string (stream string) `(progn ,@(loop for key = (let ((x (read stream nil stream))) (if (eq x stream) (loop-finish) x)) for val = (read stream) for comment = (read stream) collect (list 'defvar key (list 'quote val) (string comment))))))
(frob-keyvals-string " foo fooval foocomment bar barval barcomment car carval carcomment")
This is caused by the macro expansion of defvar when the localization support was added. Previously, we had (macroexpand '(defvar abc nil "abc")) -> (PROGN (DECLAIM (SPECIAL ABC)) (UNLESS (BOUNDP 'ABC) (SETQ ABC NIL)) (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) 'ABC) We now have: (PROGN (DECLAIM (SPECIAL ABC)) (UNLESS (BOUNDP 'ABC) (SETQ ABC NIL)) (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) (SETF (INFO VARIABLE INTL:TEXTDOMAIN 'ABC) NIL)) (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) 'ABC) I do not understand it, but that (setf info) causes the problem. When that is removed, cmucl behaves as it used to. I don't understand why that would cause the macro to be compiled again. Ray
* Raymond Toy <4BD508B2.4090006@gmail.com> : Wrote on Sun, 25 Apr 2010 23:29:54 -0400: | On 4/24/10 3:42 AM, Madhu wrote: |> Helu, here is an unpolished test case to show the problem: |> |> -=-=- |> (defmacro frob-keyvals-string (string) |> (with-input-from-string (stream string) |> `(progn ,@(loop for key = (let ((x (read stream nil stream))) |> (if (eq x stream) (loop-finish) x)) |> for val = (read stream) |> for comment = (read stream) |> collect (list 'defvar key (list 'quote val) |> (string comment)))))) |> |> (frob-keyvals-string " |> foo fooval foocomment |> bar barval barcomment |> car carval carcomment") |> | This is caused by the macro expansion of defvar when the localization | support was added. Previously, we had | | (macroexpand '(defvar abc nil "abc")) -> | (PROGN | (DECLAIM (SPECIAL ABC)) | (UNLESS (BOUNDP 'ABC) | (SETQ ABC NIL)) | (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") | (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) | 'ABC) | | We now have: | | (PROGN | (DECLAIM (SPECIAL ABC)) | (UNLESS (BOUNDP 'ABC) | (SETQ ABC NIL)) | (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") | (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) | (SETF (INFO VARIABLE INTL:TEXTDOMAIN 'ABC) NIL)) | (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) | 'ABC) | | I do not understand it, but that (setf info) causes the problem. When | that is removed, cmucl behaves as it used to. I don't understand why | that would cause the macro to be compiled again. My report may have been misleading: I do not think that macro is being compiled again, it just looks that way from the notes that CMUCL prints. I have not looked at the CMUCL code yet, but I my guess (without looking at any commits) is that this is more likely related to some source recording changes that may have been introduced. -- Madhu
On 4/25/10 11:29 PM, Raymond Toy wrote:
On 4/24/10 3:42 AM, Madhu wrote:
Helu, here is an unpolished test case to show the problem:
-=-=- (defmacro frob-keyvals-string (string) (with-input-from-string (stream string) `(progn ,@(loop for key = (let ((x (read stream nil stream))) (if (eq x stream) (loop-finish) x)) for val = (read stream) for comment = (read stream) collect (list 'defvar key (list 'quote val) (string comment))))))
(frob-keyvals-string " foo fooval foocomment bar barval barcomment car carval carcomment")
This is caused by the macro expansion of defvar when the localization support was added. Previously, we had
(macroexpand '(defvar abc nil "abc")) -> (PROGN (DECLAIM (SPECIAL ABC)) (UNLESS (BOUNDP 'ABC) (SETQ ABC NIL)) (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) 'ABC)
We now have:
(PROGN (DECLAIM (SPECIAL ABC)) (UNLESS (BOUNDP 'ABC) (SETQ ABC NIL)) (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) (SETF (INFO VARIABLE INTL:TEXTDOMAIN 'ABC) NIL)) (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) 'ABC)
I do not understand it, but that (setf info) causes the problem. When that is removed, cmucl behaves as it used to. I don't understand why that would cause the macro to be compiled again.
To confuse me even more, if defvar macroexpands to (PROGN (DECLAIM (SPECIAL ABC)) (UNLESS (BOUNDP 'ABC) (SETQ ABC NIL)) (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) (%%defvar 'abc "domain")) (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) 'ABC) Everything looks as it used to. Ray
* Raymond Toy <4BD508B2.4090006@gmail.com> : Wrote on Sun, 25 Apr 2010 23:29:54 -0400: | On 4/24/10 3:42 AM, Madhu wrote: |> Helu, here is an unpolished test case to show the problem: |> |> -=-=- |> (defmacro frob-keyvals-string (string) |> (with-input-from-string (stream string) |> `(progn ,@(loop for key = (let ((x (read stream nil stream))) |> (if (eq x stream) (loop-finish) x)) |> for val = (read stream) |> for comment = (read stream) |> collect (list 'defvar key (list 'quote val) |> (string comment)))))) |> |> (frob-keyvals-string " |> foo fooval foocomment |> bar barval barcomment |> car carval carcomment") |> | This is caused by the macro expansion of defvar when the localization | support was added. Previously, we had | | (macroexpand '(defvar abc nil "abc")) -> | (PROGN | (DECLAIM (SPECIAL ABC)) | (UNLESS (BOUNDP 'ABC) | (SETQ ABC NIL)) | (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") | (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) | 'ABC) | | We now have: | | (PROGN | (DECLAIM (SPECIAL ABC)) | (UNLESS (BOUNDP 'ABC) | (SETQ ABC NIL)) | (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") | (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) | (SETF (INFO VARIABLE INTL:TEXTDOMAIN 'ABC) NIL)) | (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) | 'ABC) | | I do not understand it, but that (setf info) causes the problem. When | that is removed, cmucl behaves as it used to. I don't understand why | that would cause the macro to be compiled again. My report may have been misleading: I do not think that macro is being compiled again, it just looks that way from the notes that CMUCL prints. I have not looked at the CMUCL code yet, but I my guess (without looking at any commits) is that this is more likely related to some source recording changes that may have been introduced. -- Madhu
On 4/26/10 6:16 AM, Madhu wrote:
* Raymond Toy <4BD508B2.4090006@gmail.com> : Wrote on Sun, 25 Apr 2010 23:29:54 -0400:
| | | We now have: | | (PROGN | (DECLAIM (SPECIAL ABC)) | (UNLESS (BOUNDP 'ABC) | (SETQ ABC NIL)) | (SETF (DOCUMENTATION 'ABC 'VARIABLE) '"abc") | (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE) | (SETF (INFO VARIABLE INTL:TEXTDOMAIN 'ABC) NIL)) | (LISP::SET-DEFVAR-SOURCE-LOCATION 'ABC (C::SOURCE-LOCATION)) | 'ABC) | | I do not understand it, but that (setf info) causes the problem. When | that is removed, cmucl behaves as it used to. I don't understand why | that would cause the macro to be compiled again.
My report may have been misleading: I do not think that macro is being compiled again, it just looks that way from the notes that CMUCL prints.
I have not looked at the CMUCL code yet, but I my guess (without looking at any commits) is that this is more likely related to some source recording changes that may have been introduced.
AFAIK, there have been no changes to source recording. I think what is happening is that the eval-when for the (setf info) form is causing the compiler to compile the top-level form. It creates a component name by looking up the source file and finds frob-kevals-string form and uses that as the component name. That's what gets printed which makes it look like it's compiling frob-keyvals-string again. But it's really just compiling the defvar. When the (setf (info ...)) is replaced by a (lisp::%%defvar ...) where the new function %%defvar just calls (setf (info ...) ..), the printed messages are much nicer. So, I think it's not really a problem. Rather it's just a poor choice of component name by the compiler. So using %%defvar is a possible solution. Ray
participants (3)
-
Madhu -
Madhu -
Raymond Toy