Add letrec to render-aware HTML forms — stepper island now SSRs

letrec in adapter-html.sx: evaluate via CEK (which handles mutual
recursion and returns a thunk), then render-value-to-html unwraps
the thunk and renders the expression with the letrec's local env.

Both islands (~layouts/header and ~home/stepper) now render
server-side with hydration markers and CSS classes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 15:41:09 +00:00
parent f4610e1799
commit fa700e0202
2 changed files with 15 additions and 5 deletions

View File

@@ -56,7 +56,7 @@
;; --------------------------------------------------------------------------
(define RENDER_HTML_FORMS
(list "if" "when" "cond" "case" "let" "let*" "begin" "do"
(list "if" "when" "cond" "case" "let" "let*" "letrec" "begin" "do"
"define" "defcomp" "defisland" "defmacro" "defstyle" "defhandler"
"deftype" "defeffect"
"map" "map-indexed" "filter" "for-each" "scope" "provide"))
@@ -173,6 +173,13 @@
(= name "case")
(render-to-html (trampoline (eval-expr expr env)) env)
;; letrec — evaluate via CEK, render the result.
;; sf-letrec returns a thunk; the thunk handler in render-value-to-html
;; unwraps it and renders the expression with the letrec's local env.
(= name "letrec")
(let ((result (eval-expr expr env)))
(render-value-to-html result env))
;; let / let* — single body: pass through. Multi: join strings.
(or (= name "let") (= name "let*"))
(let ((local (process-bindings (nth expr 1) env)))