[parenscript-devel] defpsmacro has no effect at compile-time
Peter Stirling
peter at pjstirling.plus.com
Thu Mar 7 23:07:17 UTC 2013
Hi,
When you use C-c C-k in emacs/SLIME/sbcl produces the output:
"(function () {
var div1 = createElement(div);
return null;
})();"
If you do C-C C-k again though, you get the (expected) output:
"(function () {
var div = document.createElement('DIV');
return null;
})();"
The problem is (I think) that DEFPSMACRO expands into a PROGN and
therefore the SETFs have no effect until load time, by which point the
PS form has already been converted into the string.
If changed to an EVAL-WHEN:
(defmacro defpsmacro (name args &body body)
(defined-operator-override-check name
(multiple-value-bind (macro-fn-form effective-lambda-list)
(make-ps-macro-function args body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(setf (gethash ',name *macro-toplevel*) ,macro-fn-form)
(setf (gethash ',name *macro-toplevel-lambda-list*)
',effective-lambda-list)
',name))))
Then it compiles as expected the first time as well.
More information about the parenscript-devel
mailing list