Unify CEK callable dispatch, add named-let transpiler, full stdlib
Three changes that together enable the full 46-function stdlib migration:
1. CEK callable unification (spec/evaluator.sx):
cek-call now routes both native callables and SX lambdas through
continue-with-call, so replacing a native function with an SX lambda
doesn't change shift/reset behavior.
2. Named-let transpiler support (hosts/javascript/transpiler.sx):
(let loop ((i 0)) body...) now transpiles to a named IIFE:
(function loop(i) { body })(0)
This was the cause of the 3 test regressions (produced [object Object]).
3. Full stdlib via runtime eval (hosts/javascript/bootstrap.py):
stdlib.sx is eval'd at runtime (not transpiled) so its defines go
into PRIMITIVES without shadowing module-scope variables that the
transpiled evaluator uses directly.
stdlib.sx now contains all 46 library functions:
Logic: not
Comparison: != <= >= eq? eqv? equal?
Predicates: boolean? number? string? list? dict? continuation?
zero? odd? even? empty?
Arithmetic: inc dec abs ceil round min max clamp
Collections: first last rest nth cons append reverse flatten
range chunk-every zip-pairs
Dict: vals has-key? assoc dissoc into
Strings: upcase downcase string-length substring string-contains?
starts-with? ends-with? split join replace contains?
Text: pluralize escape parse-datetime assert
All hosts: JS 957+1080, Python 744, OCaml 952 — zero regressions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1540,13 +1540,18 @@
|
||||
(kont-push (make-deref-frame env) kont))))
|
||||
|
||||
;; cek-call — call a function via CEK (replaces invoke)
|
||||
;; cek-call — unified function dispatch
|
||||
;; Both lambdas and native callables go through continue-with-call
|
||||
;; so they interact identically with the continuation stack.
|
||||
;; This is critical: replacing a native callable with an SX lambda
|
||||
;; (e.g. stdlib.sx) must not change shift/reset behavior.
|
||||
(define cek-call
|
||||
(fn (f args)
|
||||
(let ((a (if (nil? args) (list) args)))
|
||||
(cond
|
||||
(nil? f) nil
|
||||
(lambda? f) (cek-run (continue-with-call f a (dict) a (list)))
|
||||
(callable? f) (apply f a)
|
||||
(or (lambda? f) (callable? f))
|
||||
(cek-run (continue-with-call f a (dict) a (list)))
|
||||
:else nil))))
|
||||
|
||||
;; reactive-shift-deref: the heart of deref-as-shift
|
||||
|
||||
Reference in New Issue
Block a user