define-entryの引数。

生成されるコードを見ると、sxmlを渡している。

(define-entry (greeting)
  (kahua:xml-template->sxml
   page-template
   :body (div/ (@/ (id "body"))
	       (h1/ "Hello, Kahua!")
	       (a/cont/ (@@/ (cont version))
			"version"))))

テストしてみた。

; OK
(define-entry (sample)
  (html/
   (head/ (title/ "sample"))
   (body/ "sample")
   ))

; NG
; *** ERROR: pair required, but got hoge
(define-entry (sample2-1)
  (html:
   (head: (title: "sample2-1"))
   (body: "sample2-1")))

; OK
(define-entry (sample2-2)
  (node-set:
   (html:
    (head: (title: "sample2-2"))
   (body: "sample2-2"))))

; NG
; *** ERROR: pair required, but got hoge
(define-entry (sample3-1)
  `(hoge
    ,(html:
      (head: (title: "sample3-1"))
      (body: "sample3-1"))))

; OK
(define-entry (sample3-2)
  `(node-set
    ,(html:
      (head: (title: "sample3-2"))
      (body: "sample3-2"))))

(node-set/)

(head/)や(body/)、(div/)などをひとつにまとめたいときに使う。

(define-entry (sample4)
  (html/
   (head/ (title/ "sample4"))
   (body/ (div/ ) (div/ ))))

でも動くけど、チュートリアルだとまとめて引数をひとつにするために使ってる。

モナド

(kahua.elemの)/で終わる関数にはモナドが使われてるよ、、
(node-set/)とかは、関数を返して、その関数は、自分の最後に引数を追加してる。
関数を返すから

(list (div/) (div/))

だと駄目なのか。こっちだと

<div><div/><div><div/>