1

如何评估传递给psParenscript 中宏的代码?

(let ((x 1))
  (format nil "~a" (parenscript:ps x))) 
;; => "x;" but I would like "1;"

我知道这ps是一个宏,是不评估的原因,但是如何评估代码以传递给ps宏?

4

2 回答 2

2

您的示例使用ps:lisp

(let ((x 1))
  (format nil "~a" (ps:ps (ps:lisp x))))
"1;"

它在文档的第一部分介绍:https ://common-lisp.net/project/parenscript/reference.html#section-ps-compiler

于 2020-09-17T07:05:51.283 回答
0

我知道了:

(defmacro lisp-to-js (lisp)
  (eval ``(parenscript:ps ,,lisp)))
(let ((x 1))
  (format nil "~a" (lisp-to-js x)))
;; => "1;"
于 2020-09-16T16:06:37.860 回答