Closed farooqkz closed 4 years ago
Normally one uses setf to set the value of a variable that has already been defined using defparameter
. That's why you're seeing so many warnings.
The problem's not warnings. The problem's that (with-html-string a) returns empty string rather than the generated string of html tags.
@ruricolist Hello?
@ruricolist Hello?
I haven't forgotten you, but I haven't had a chance to look into this yet.
Okay. Look into it whenever you've got some free time, whenever you want :)
The short answer is that to do what you want, you need to preface the variable with #.
:
(spinneret:with-html-string #.a)
The long answer is that with-html-string
is a macro, not a function. It sees its arguments before, not after, they're evaluated.
Try it for yourself:
(defmacro my-quote (arg)
(print arg))
(my-quote a) ;; Prints A
Evaluation in Lisp happens in phases: first code is read, then it's macro-expanded, and then it's evaluated. If you want a macro to see the value of a variable, you have to move it into an earlier phase. That's what #.
does: it evaluates at read time.
(my-quote #.a)
(:P "H" (:SUP "ello") (:SUB "i"))
Thank you very much for solving my problem and for teaching me CL. So I close this now.
I'm not sure how to use it:
As you see (with-html-string a) does not work as expected. Thanks
Edit0: The problem's not with the warnings. The problem's that
(with-html-string a)
does not return what(with-html-string (:P "H" (:SUP "ello) (:SUB "i")))
returns