Add provide/context/emit!/emitted — render-time dynamic scope

Four new primitives for scoped downward value passing and upward
accumulation through the render tree. Specced in .sx, bootstrapped
to Python and JS across all adapters (eval, html, sx, dom, async).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 02:58:21 +00:00
parent 41097eeef9
commit ea2b71cfa3
14 changed files with 436 additions and 18 deletions

View File

@@ -269,6 +269,13 @@
;; (collected bucket) → list
;; (clear-collected! bucket) → void
;;
;; Dynamic scope (provide/context/emit!):
;; (provide-push! name val) → void
;; (provide-pop! name) → void
;; (context name &rest def) → value from nearest provider
;; (emit! name value) → void (append to provider accumulator)
;; (emitted name) → list of emitted values
;;
;; From parser.sx:
;; (sx-serialize val) → SX source string (aliased as serialize above)
;; --------------------------------------------------------------------------