Common lisp 未在CL-WHO模板中呈现的字符串

Common lisp 未在CL-WHO模板中呈现的字符串,common-lisp,cl-who,Common Lisp,Cl Who,这段代码没有输出我想要的。 我期望它的输出: (require :cl-who) (defmacro rawpage ((&rest head) &body body) `(cl-who:with-html-output-to-string (*standard-output* nil :prologue t) (:html (:head (:meta :charset "utf-8") ,@head) (:body

这段代码没有输出我想要的。 我期望它的输出:

(require :cl-who)
(defmacro rawpage ((&rest head) &body body)
  `(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
    (:html
    (:head
      (:meta :charset "utf-8")
      ,@head)
    (:body
      ,@body))))

(defmacro str+ (&rest strs)
  `(concatenate 'string ,@strs))

(rawpage () (:div (str+ "hello," "name")))
<html><head><meta charset='utf-8' /></head><body><div>hello,name</div></body></html>
你好,name
但是,它输出:

(require :cl-who)
(defmacro rawpage ((&rest head) &body body)
  `(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
    (:html
    (:head
      (:meta :charset "utf-8")
      ,@head)
    (:body
      ,@body))))

(defmacro str+ (&rest strs)
  `(concatenate 'string ,@strs))

(rawpage () (:div (str+ "hello," "name")))
<html><head><meta charset='utf-8' /></head><body><div>hello,name</div></body></html>


谁能告诉我为什么?我正在使用SBCL。

您的问题是,在CL-WHO中,非常量字符串应该放在
str
中,如下所示:

<html><head><meta charset='utf-8' /></head><body><div></div></body></html>

您的问题是,在CL-WHO中,非常量字符串应该放在
str
中,如下所示:

<html><head><meta charset='utf-8' /></head><body><div></div></body></html>

一个好的开始可能是执行
(macroexpand-1'(rawpage()(:div(str+“hello”,“name”)))
,看看它实际扩展到什么。其次,最好将
str+
宏替换为
(defun str+(&rest strs)(format nil“~{~a~}”strs)
(永远不要使用宏,函数可以做到这一点)。好的第一步可能是执行
(macroexpand-1'(rawpage():div(str+“hello”,“name”))
并查看它实际扩展到什么。其次,最好将
str+
宏替换为
(defun str+(&rest strs)(格式化为nil”~{~a~}”strs)
(不要使用宏,因为函数会起作用)。