Adopt Step 7 language features across SX codebase

112 conversions across 19 .sx files using match, let-match, and pipe operators:

match (17): type/value dispatch replacing cond/if chains
  - lib/vm.sx: HO form dispatch (for-each/map/filter/reduce/some/every?)
  - lib/tree-tools.sx: node-display, node-matches?, rename, count, replace, free-symbols
  - lib/types.sx: narrow-type, substitute-in-type, infer-type, resolve-type
  - web/engine.sx: default-trigger, resolve-target, classify-trigger
  - web/deps.sx: scan-refs-walk, scan-io-refs-walk

let-match (89): dict destructuring replacing (get d "key") patterns
  - shared/page-functions.sx (20), blog/admin.sx (17), pub-api.sx (13)
  - events/ layouts/page/tickets/entries/forms (27 total)
  - specs-explorer.sx (7), federation/social.sx (3), lib/ small files (3)

-> pipes (6): replacing triple-chained gets in lib/vm.sx
  - frame-closure → closure-code → code-bytecode chains

Also: lib/vm.sx accessor upgrades (get vm "sp" → vm-sp vm throughout)

2650/2650 tests pass, zero regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 20:49:02 +00:00
parent aee4770a6a
commit c0665ba58e
19 changed files with 4974 additions and 3771 deletions

View File

@@ -121,57 +121,63 @@
(case
slug
"bundle-analyzer"
(let
((data (helper "bundle-analyzer-data")))
(let-match
{:total-macros total-macros :pages pages :io-count io-count :pure-count pure-count :total-components total-components}
(helper "bundle-analyzer-data")
(quasiquote
(~analyzer/bundle-analyzer-content
:pages (unquote (get data "pages"))
:total-components (unquote (get data "total-components"))
:total-macros (unquote (get data "total-macros"))
:pure-count (unquote (get data "pure-count"))
:io-count (unquote (get data "io-count")))))
:pages (unquote pages)
:total-components (unquote total-components)
:total-macros (unquote total-macros)
:pure-count (unquote pure-count)
:io-count (unquote io-count))))
"routing-analyzer"
(let
((data (helper "routing-analyzer-data")))
(let-match
{:pages pages :total-pages total-pages :server-count server-count :registry-sample registry-sample :client-count client-count}
(helper "routing-analyzer-data")
(quasiquote
(~routing-analyzer/content
:pages (unquote (get data "pages"))
:total-pages (unquote (get data "total-pages"))
:client-count (unquote (get data "client-count"))
:server-count (unquote (get data "server-count"))
:registry-sample (unquote (get data "registry-sample")))))
:pages (unquote pages)
:total-pages (unquote total-pages)
:client-count (unquote client-count)
:server-count (unquote server-count)
:registry-sample (unquote registry-sample))))
"data-test"
(let
((data (helper "data-test-data")))
(let-match
{:server-time server-time :transport transport :phase phase :items items}
(helper "data-test-data")
(quasiquote
(~data-test/content
:server-time (unquote (get data "server-time"))
:items (unquote (get data "items"))
:phase (unquote (get data "phase"))
:transport (unquote (get data "transport")))))
:server-time (unquote server-time)
:items (unquote items)
:phase (unquote phase)
:transport (unquote transport))))
"async-io"
(quote (~async-io-demo/content))
"affinity"
(let
((data (helper "affinity-demo-data")))
(let-match
{:components components :page-plans page-plans}
(helper "affinity-demo-data")
(quasiquote
(~affinity-demo/content
:components (unquote (get data "components"))
:page-plans (unquote (get data "page-plans")))))
:components (unquote components)
:page-plans (unquote page-plans))))
"optimistic"
(let
((data (helper "optimistic-demo-data")))
(let-match
{:server-time server-time :items items}
(helper "optimistic-demo-data")
(quasiquote
(~optimistic-demo/content
:items (unquote (get data "items"))
:server-time (unquote (get data "server-time")))))
:items (unquote items)
:server-time (unquote server-time))))
"offline"
(let
((data (helper "offline-demo-data")))
(let-match
{:server-time server-time :notes notes}
(helper "offline-demo-data")
(quasiquote
(~offline-demo/content
:notes (unquote (get data "notes"))
:server-time (unquote (get data "server-time")))))
:notes (unquote notes)
:server-time (unquote server-time))))
:else (quote (~plans/isomorphic/plan-isomorphic-content))))))
(define
@@ -262,15 +268,18 @@
((found-spec (find-spec slug)))
(if
found-spec
(let
((src (helper "read-spec-file" (get found-spec "filename"))))
(quasiquote
(~specs/detail-content
:spec-title (unquote (get found-spec "title"))
:spec-desc (unquote (get found-spec "desc"))
:spec-filename (unquote (get found-spec "filename"))
:spec-source (unquote src)
:spec-prose (unquote (get found-spec "prose")))))
(let-match
{:desc desc :prose prose :title title :filename filename}
found-spec
(let
((src (helper "read-spec-file" filename)))
(quasiquote
(~specs/detail-content
:spec-title (unquote title)
:spec-desc (unquote desc)
:spec-filename (unquote filename)
:spec-source (unquote src)
:spec-prose (unquote prose)))))
(quasiquote (~specs/not-found :slug (unquote slug)))))))))
(define
@@ -324,54 +333,67 @@
(case
slug
"self-hosting"
(quasiquote
(~specs/bootstrapper-self-hosting-content
:py-sx-source (unquote (get data "py-sx-source"))
:g0-output (unquote (get data "g0-output"))
:g1-output (unquote (get data "g1-output"))
:defines-matched (unquote (get data "defines-matched"))
:defines-total (unquote (get data "defines-total"))
:g0-lines (unquote (get data "g0-lines"))
:g0-bytes (unquote (get data "g0-bytes"))
:verification-status (unquote (get data "verification-status"))))
(let-match
{:g1-output g1-output :py-sx-source py-sx-source :g0-bytes g0-bytes :verification-status verification-status :g0-output g0-output :defines-total defines-total :defines-matched defines-matched :g0-lines g0-lines}
data
(quasiquote
(~specs/bootstrapper-self-hosting-content
:py-sx-source (unquote py-sx-source)
:g0-output (unquote g0-output)
:g1-output (unquote g1-output)
:defines-matched (unquote defines-matched)
:defines-total (unquote defines-total)
:g0-lines (unquote g0-lines)
:g0-bytes (unquote g0-bytes)
:verification-status (unquote verification-status))))
"self-hosting-js"
(quasiquote
(~specs/bootstrapper-self-hosting-js-content
:js-sx-source (unquote (get data "js-sx-source"))
:defines-matched (unquote (get data "defines-matched"))
:defines-total (unquote (get data "defines-total"))
:js-sx-lines (unquote (get data "js-sx-lines"))
:verification-status (unquote (get data "verification-status"))))
(let-match
{:js-sx-source js-sx-source :verification-status verification-status :js-sx-lines js-sx-lines :defines-total defines-total :defines-matched defines-matched}
data
(quasiquote
(~specs/bootstrapper-self-hosting-js-content
:js-sx-source (unquote js-sx-source)
:defines-matched (unquote defines-matched)
:defines-total (unquote defines-total)
:js-sx-lines (unquote js-sx-lines)
:verification-status (unquote verification-status))))
"python"
(quasiquote
(~specs/bootstrapper-py-content
:bootstrapper-source (unquote (get data "bootstrapper-source"))
:bootstrapped-output (unquote (get data "bootstrapped-output"))))
(let-match
{:bootstrapper-source bootstrapper-source :bootstrapped-output bootstrapped-output}
data
(quasiquote
(~specs/bootstrapper-py-content
:bootstrapper-source (unquote bootstrapper-source)
:bootstrapped-output (unquote bootstrapped-output))))
"page-helpers"
(let
((ph-data (helper "page-helpers-demo-data")))
(let-match
{:attr-result attr-result :sf-source sf-source :ref-ms ref-ms :req-attrs req-attrs :attr-detail attr-detail :attr-keys attr-keys :server-total-ms server-total-ms :attr-ms attr-ms :comp-ms comp-ms :routing-ms routing-ms :comp-source comp-source :routing-result routing-result :sf-categories sf-categories :sf-total sf-total :sf-ms sf-ms :ref-sample ref-sample}
(helper "page-helpers-demo-data")
(quasiquote
(~page-helpers-demo/content
:sf-categories (unquote (get ph-data "sf-categories"))
:sf-total (unquote (get ph-data "sf-total"))
:sf-ms (unquote (get ph-data "sf-ms"))
:ref-sample (unquote (get ph-data "ref-sample"))
:ref-ms (unquote (get ph-data "ref-ms"))
:attr-result (unquote (get ph-data "attr-result"))
:attr-ms (unquote (get ph-data "attr-ms"))
:comp-source (unquote (get ph-data "comp-source"))
:comp-ms (unquote (get ph-data "comp-ms"))
:routing-result (unquote (get ph-data "routing-result"))
:routing-ms (unquote (get ph-data "routing-ms"))
:server-total-ms (unquote (get ph-data "server-total-ms"))
:sf-source (unquote (get ph-data "sf-source"))
:attr-detail (unquote (get ph-data "attr-detail"))
:req-attrs (unquote (get ph-data "req-attrs"))
:attr-keys (unquote (get ph-data "attr-keys")))))
:else (quasiquote
(~specs/bootstrapper-js-content
:bootstrapper-source (unquote (get data "bootstrapper-source"))
:bootstrapped-output (unquote (get data "bootstrapped-output"))))))))))
:sf-categories (unquote sf-categories)
:sf-total (unquote sf-total)
:sf-ms (unquote sf-ms)
:ref-sample (unquote ref-sample)
:ref-ms (unquote ref-ms)
:attr-result (unquote attr-result)
:attr-ms (unquote attr-ms)
:comp-source (unquote comp-source)
:comp-ms (unquote comp-ms)
:routing-result (unquote routing-result)
:routing-ms (unquote routing-ms)
:server-total-ms (unquote server-total-ms)
:sf-source (unquote sf-source)
:attr-detail (unquote attr-detail)
:req-attrs (unquote req-attrs)
:attr-keys (unquote attr-keys))))
:else (let-match
{:bootstrapper-source bootstrapper-source :bootstrapped-output bootstrapped-output}
data
(quasiquote
(~specs/bootstrapper-js-content
:bootstrapper-source (unquote bootstrapper-source)
:bootstrapped-output (unquote bootstrapped-output))))))))))
(define
test
@@ -379,24 +401,26 @@
(slug)
(if
(nil? slug)
(let
((data (helper "run-modular-tests" "all")))
(let-match
{:server-results server-results :parser-source parser-source :framework-source framework-source :eval-source eval-source :router-source router-source :engine-source engine-source :render-source render-source :deps-source deps-source}
(helper "run-modular-tests" "all")
(quasiquote
(~testing/overview-content
:server-results (unquote (get data "server-results"))
:framework-source (unquote (get data "framework-source"))
:eval-source (unquote (get data "eval-source"))
:parser-source (unquote (get data "parser-source"))
:router-source (unquote (get data "router-source"))
:render-source (unquote (get data "render-source"))
:deps-source (unquote (get data "deps-source"))
:engine-source (unquote (get data "engine-source")))))
:server-results (unquote server-results)
:framework-source (unquote framework-source)
:eval-source (unquote eval-source)
:parser-source (unquote parser-source)
:router-source (unquote router-source)
:render-source (unquote render-source)
:deps-source (unquote deps-source)
:engine-source (unquote engine-source))))
(case
slug
"runners"
(quote (~testing/runners-content))
:else (let
((data (helper "run-modular-tests" slug)))
:else (let-match
{:server-results server-results :spec-source spec-source :framework-source framework-source}
(helper "run-modular-tests" slug)
(case
slug
"eval"
@@ -404,67 +428,67 @@
(~testing/spec-content
:spec-name "eval"
:spec-title "Evaluator Tests"
:spec-desc "81 tests covering the core evaluator and all primitives."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-desc "81 tests covering the core evaluator — literals, symbols, special forms, closures."
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"parser"
(quasiquote
(~testing/spec-content
:spec-name "parser"
:spec-title "Parser Tests"
:spec-desc "39 tests covering tokenization and parsing."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"router"
(quasiquote
(~testing/spec-content
:spec-name "router"
:spec-title "Router Tests"
:spec-desc "18 tests covering client-side route matching."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"render"
(quasiquote
(~testing/spec-content
:spec-name "render"
:spec-title "Renderer Tests"
:spec-desc "23 tests covering HTML rendering."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"deps"
(quasiquote
(~testing/spec-content
:spec-name "deps"
:spec-title "Dependency Analysis Tests"
:spec-desc "33 tests covering component dependency analysis."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"engine"
(quasiquote
(~testing/spec-content
:spec-name "engine"
:spec-title "Engine Tests"
:spec-desc "37 tests covering engine pure functions."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
"orchestration"
(quasiquote
(~testing/spec-content
:spec-name "orchestration"
:spec-title "Orchestration Tests"
:spec-desc "17 tests covering orchestration."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:spec-source (unquote spec-source)
:framework-source (unquote framework-source)
:server-results (unquote server-results)))
:else (quasiquote
(~testing/overview-content
:server-results (unquote (get data "server-results"))))))))))
:server-results (unquote server-results)))))))))
(define
reference
@@ -478,26 +502,32 @@
(case
slug
"attributes"
(quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote (get data "req-attrs")))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote (get data "beh-attrs")))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote (get data "uniq-attrs")))))
(let-match
{:req-attrs req-attrs :beh-attrs beh-attrs :uniq-attrs uniq-attrs}
data
(quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote req-attrs))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote beh-attrs))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote uniq-attrs)))))
"headers"
(quasiquote
(~reference/headers-content
:req-table (~docs/headers-table-from-data
:title "Request Headers"
:headers (unquote (get data "req-headers")))
:resp-table (~docs/headers-table-from-data
:title "Response Headers"
:headers (unquote (get data "resp-headers")))))
(let-match
{:req-headers req-headers :resp-headers resp-headers}
data
(quasiquote
(~reference/headers-content
:req-table (~docs/headers-table-from-data
:title "Request Headers"
:headers (unquote req-headers))
:resp-table (~docs/headers-table-from-data
:title "Response Headers"
:headers (unquote resp-headers)))))
"events"
(quasiquote
(~reference/events-content
@@ -514,17 +544,20 @@
:col1 "Method"
:col2 "Description"
:items (unquote (get data "js-api-list")))))
:else (quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote (get data "req-attrs")))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote (get data "beh-attrs")))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote (get data "uniq-attrs"))))))))))
:else (let-match
{:req-attrs req-attrs :beh-attrs beh-attrs :uniq-attrs uniq-attrs}
data
(quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote req-attrs))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote beh-attrs))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote uniq-attrs))))))))))
(define
reference-detail
@@ -541,39 +574,48 @@
(if
(get data "attr-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/attr-detail-content
:title (unquote (get data "attr-title"))
:description (unquote (get data "attr-description"))
:demo (unquote (get data "attr-demo"))
:example-code (unquote (get data "attr-example"))
:handler-code (unquote (get data "attr-handler"))
:wire-placeholder-id (unquote (get data "attr-wire-id"))))))
(let-match
{:attr-handler attr-handler :attr-title attr-title :attr-example attr-example :attr-description attr-description :attr-demo attr-demo :attr-wire-id attr-wire-id}
data
(quasiquote
(~reference/attr-detail-content
:title (unquote attr-title)
:description (unquote attr-description)
:demo (unquote attr-demo)
:example-code (unquote attr-example)
:handler-code (unquote attr-handler)
:wire-placeholder-id (unquote attr-wire-id))))))
"headers"
(let
((data (helper "header-detail-data" slug)))
(if
(get data "header-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/header-detail-content
:title (unquote (get data "header-title"))
:direction (unquote (get data "header-direction"))
:description (unquote (get data "header-description"))
:example-code (unquote (get data "header-example"))
:demo (unquote (get data "header-demo"))))))
(let-match
{:header-description header-description :header-demo header-demo :header-title header-title :header-example header-example :header-direction header-direction}
data
(quasiquote
(~reference/header-detail-content
:title (unquote header-title)
:direction (unquote header-direction)
:description (unquote header-description)
:example-code (unquote header-example)
:demo (unquote header-demo))))))
"events"
(let
((data (helper "event-detail-data" slug)))
(if
(get data "event-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/event-detail-content
:title (unquote (get data "event-title"))
:description (unquote (get data "event-description"))
:example-code (unquote (get data "event-example"))
:demo (unquote (get data "event-demo"))))))
(let-match
{:event-example event-example :event-demo event-demo :event-description event-description :event-title event-title}
data
(quasiquote
(~reference/event-detail-content
:title (unquote event-title)
:description (unquote event-description)
:example-code (unquote event-example)
:demo (unquote event-demo))))))
:else nil))))
(define