Step 11: define-foreign FFI + transpiler mutable globals fix
FFI: define-foreign special form in evaluator — registry, param parser, kwargs parser, binding resolver, type checker, lambda builder, dispatcher. Generates callable lambdas that route through foreign-dispatch to host-call. 24 tests in test-foreign.sx (registry, parsing, resolution, type checking). Transpiler: fix mutable global ref emission — ml-emit-define now emits both X_ref = ref <init> and X_ = <init> for starred globals (was missing the ref definition entirely, broke retranspilation). Add *provide-batch-depth*, *provide-batch-queue*, *provide-subscribers* to mutable globals list. Evaluator: add missing (define *provide-batch-queue* (list)) and (define *provide-subscribers* (dict)) — were only in hand-edited sx_ref.ml. Known: 36 bind-tracking + 8 capability test failures on retranspilation (pre-existing transpiler local-ref shadowing bug, not caused by FFI). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -285,7 +285,14 @@
|
||||
|
||||
(define
|
||||
ml-mutable-globals
|
||||
(list "*strict*" "*prim-param-types*" "*last-error-kont*" "*bind-tracking*"))
|
||||
(list
|
||||
"*strict*"
|
||||
"*prim-param-types*"
|
||||
"*last-error-kont*"
|
||||
"*bind-tracking*"
|
||||
"*provide-batch-depth*"
|
||||
"*provide-batch-queue*"
|
||||
"*provide-subscribers*"))
|
||||
|
||||
(define
|
||||
ml-is-mutable-global?
|
||||
@@ -1824,7 +1831,16 @@
|
||||
"\n")))))
|
||||
(if
|
||||
(ml-is-mutable-global? name)
|
||||
(str "let " ml-name " =\n !" ml-name "ref\n")
|
||||
(str
|
||||
"let "
|
||||
ml-name
|
||||
"ref = ref "
|
||||
(ml-expr val-expr)
|
||||
"\nand "
|
||||
ml-name
|
||||
" =\n "
|
||||
(ml-expr val-expr)
|
||||
"\n")
|
||||
(str "let " ml-name " =\n " (ml-expr val-expr) "\n"))))))))
|
||||
|
||||
(define
|
||||
@@ -1935,5 +1951,14 @@
|
||||
"\n")))))
|
||||
(if
|
||||
(ml-is-mutable-global? name)
|
||||
(str "let rec " ml-name " =\n !" ml-name "ref\n")
|
||||
(str
|
||||
"let rec "
|
||||
ml-name
|
||||
"ref = ref "
|
||||
(ml-expr val-expr)
|
||||
"\nand "
|
||||
ml-name
|
||||
" =\n "
|
||||
(ml-expr val-expr)
|
||||
"\n")
|
||||
(str "let rec " ml-name " =\n " (ml-expr val-expr) "\n")))))))
|
||||
|
||||
Reference in New Issue
Block a user