Oops, forgot to attach the file.

On 07/03/13 23:07, Peter Stirling wrote:
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.

_______________________________________________
parenscript-devel mailing list
[email protected]
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel

(eval-when (:compile-toplevel :load-toplevel :execute)
  (ql:quickload "parenscript"))

(defpackage #:ps-test
  (:use #:cl #:ps))

(in-package #:ps-test)

(defpsmacro create-element (type)
  `(chain document (create-element ,(symbol-name type))))

(defun test ()
  (ps (let ((div (create-element div)))
        nil)))

(test)
_______________________________________________
parenscript-devel mailing list
[email protected]
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel

Reply via email to