Fix home-stepper paren bugs, harden defisland multi-body, add SX Tools essay

Two paren bugs in home-stepper.sx caused the home page to render blank:

1. Line 222 had one extra ) that prematurely closed the letrec bindings
   list — rebuild-preview and do-back became body expressions instead
   of bindings, making them undefined in scope.

2. Lines 241-308 were outside the let/letrec scope entirely — the outer
   let closed at line 240, so freeze-scope, cookie restore, source
   parsing, and the entire div rendering tree had no access to signals
   or letrec functions.

Also hardens defisland to wrap multi-expression bodies in (begin ...),
matching the Python-side fix from 9f0c541. Both spec/evaluator.sx and
the OCaml transpiled sx_ref.ml are updated.

Adds SX Tools essay under Applications — the revised plan for structural
tree reading/editing tools for .sx files, motivated by this exact bug.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 17:52:16 +00:00
parent 1777f631a5
commit c18f46278f
6 changed files with 223 additions and 8 deletions

View File

@@ -734,13 +734,17 @@
(define sf-defisland
(fn ((args :as list) (env :as dict))
;; (defisland ~name (params) body)
;; (defisland ~name (params) body...)
;; Like defcomp but creates an island (reactive component).
;; Islands have the same calling convention as components but
;; render with a reactive context on the client.
;; Multi-expression bodies are wrapped in (begin ...).
(let ((name-sym (first args))
(params-raw (nth args 1))
(body (last args))
(body-exprs (slice args 2))
(body (if (= (len body-exprs) 1)
(first body-exprs)
(cons (make-symbol "begin") body-exprs)))
(comp-name (strip-prefix (symbol-name name-sym) "~"))
(parsed (parse-comp-params params-raw))
(params (first parsed))