macro that writes macros



Hi,

I'm learning lisp and tried to make this little program to write a web
page:


(defmacro new-tag (name)
(let ((sname (string-downcase (symbol-name name))))
`(defmacro ,name (&rest content)
`(progn
(format t "<~a>~%" ,',sname)
,@content
(format t "</~a>~%" ,',sname)))))

(new-tag html)
(new-tag head)
(new-tag title)
(new-tag body)
(new-tag p)

;; With that, now a web page can be "self-generated":
(html
(head
(title "My web page"))
(body
(p "Hello world")))


And it works. But then I thought about combining all those "(new-
tag ...)" like this:

(defmacro new-tags (&rest tags)
(dolist (tag tags)
`(new-tag ,tag)))

(new-tags html head title body p)

But it doesn't work! I tried without the "`" nor the "," in the "new-
tags" definition and it doesn't work either. I have been fighting with
this simple-looking problem for a long time, reading docs and stuff,
and I can't make it work anyway nor see what is wrong! Anyone has some
advice on what's going on or what I should check?

Thanks!
jordi
.



Relevant Pages