Begin is not sequential!! added by sugarwren on Sat Oct 26 18:00:15 2019

(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 "</" (symbol->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 "<head>This is a page head</head><p>here is a paragraph</p><p>here is another</p><body></body><html></html>"