macro that writes macros
- From: jordi.burguet.castell@xxxxxxxxx
- Date: Sat, 29 Dec 2007 18:13:39 -0800 (PST)
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
.
- Follow-Ups:
- Re: macro that writes macros
- From: Sacha
- Re: macro that writes macros
- From: Leandro Rios
- Re: macro that writes macros
- From: Dan Bensen
- Re: macro that writes macros
- From: John Thingstad
- Re: macro that writes macros
- From: Barry Margolin
- Re: macro that writes macros
- Prev by Date: Re: self-managed freelist for class instances
- Next by Date: Re: RFC: Extending method specializers
- Previous by thread: Re: SynFlood mitigation tool on linux
- Next by thread: Re: macro that writes macros
- Index(es):
Relevant Pages
|