Add :effects annotations to all spec files and update bootstrappers
Bootstrappers (bootstrap_py.py, js.sx) now skip :effects keyword in define forms, enabling effect annotations throughout the spec without changing generated output. Annotated 180+ functions across 14 spec files: - signals.sx: signal/deref [] pure, reset!/swap!/effect/batch [mutation] - engine.sx: parse-* [] pure, morph-*/swap-* [mutation io] - orchestration.sx: all [mutation io] (browser event binding) - adapter-html.sx: render-* [render] - adapter-dom.sx: render-* [render], reactive-* [render mutation] - adapter-sx.sx: aser-* [render] - adapter-async.sx: async-render-*/async-aser-* [render io] - parser.sx: all [] pure - render.sx: predicates [] pure, process-bindings [mutation] - boot.sx: all [mutation io] (browser init) - deps.sx: scan-*/transitive-* [] pure, compute-all-* [mutation] - router.sx: all [] pure (URL matching) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -664,7 +664,12 @@ class PyEmitter:
|
||||
def _emit_define(self, expr, indent: int = 0) -> str:
|
||||
pad = " " * indent
|
||||
name = expr[1].name if isinstance(expr[1], Symbol) else str(expr[1])
|
||||
val_expr = expr[2]
|
||||
# Handle (define name :effects [...] value) — skip :effects annotation
|
||||
if (len(expr) >= 5 and isinstance(expr[2], Keyword)
|
||||
and expr[2].name == "effects"):
|
||||
val_expr = expr[4]
|
||||
else:
|
||||
val_expr = expr[2]
|
||||
# Always emit fn-bodied defines as def statements for flat control flow
|
||||
if (isinstance(val_expr, list) and val_expr and
|
||||
isinstance(val_expr[0], Symbol) and val_expr[0].name in ("fn", "lambda")):
|
||||
@@ -675,7 +680,12 @@ class PyEmitter:
|
||||
def _emit_define_async(self, expr, indent: int = 0) -> str:
|
||||
"""Emit a define-async form as an async def statement."""
|
||||
name = expr[1].name if isinstance(expr[1], Symbol) else str(expr[1])
|
||||
val_expr = expr[2]
|
||||
# Handle (define-async name :effects [...] value) — skip :effects annotation
|
||||
if (len(expr) >= 5 and isinstance(expr[2], Keyword)
|
||||
and expr[2].name == "effects"):
|
||||
val_expr = expr[4]
|
||||
else:
|
||||
val_expr = expr[2]
|
||||
if (isinstance(val_expr, list) and val_expr and
|
||||
isinstance(val_expr[0], Symbol) and val_expr[0].name in ("fn", "lambda")):
|
||||
return self._emit_define_as_def(name, val_expr, indent, is_async=True)
|
||||
|
||||
Reference in New Issue
Block a user