(define-syntax generate-html-tag (syntax-rules () ((generate-html-tag x) (define (x . args) (begin (display (string-append "<" (symbol->string 'x) ">")) (for-each (lambda (arg) (cond ((string? arg) (display arg)) ((procedure? arg) (arg)) (else '()))) args) (display (string-append "string 'x) ">"))))))) (generate-html-tag html) (generate-html-tag head) (generate-html-tag body) (generate-html-tag p) (html (head "This is a page head") (body (p "here is a paragraph") (p "here is another"))) ;; above prints "This is a page head

here is a paragraph

here is another

"