Add shen-swift as a Ratatoskr stage-2 target (Swift) - #7
Merged
Conversation
shen-swift is a tree-walking KLambda interpreter (iOS-capable), not a
compiler, so its stage-2 builder has nothing to code-generate: the
artifact IS the shaken slice, executed by the shen-swift binary — the
same runtime-reference relationship the lua/julia targets have. The win
is boot speed: a ~200-line shaken kernel vs the full ~2500-line kernel.
builders/swift/build.sh copies the shaken kernel.kl + user .kl next to a
`run` launcher that drives shen-swift in `--shaken` mode (a new flag on
the shen-swift side: boot the slice — defuns, native overrides,
(shen.initialise), then top-level forms — and run the program to
completion, no full kernel, no launcher). Load order mirrors the
Scheme/Lua builders.
Wired: builders.json `swift` entry; `{shen_swift}` subst + swift→shen-swift
sibling map in both the Go CLI (main.go) and the Python oracle
(ratatoskr_cli.py). Verified `fib 20 = 6765` via `ratatoskr run --target
swift` and byte-identical with shen-lua under `bifrost --shake`. With
this, all eight bifrost ports have a builder.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
shen-swift is a tree-walking KLambda interpreter (iOS-capable), not a compiler — so its stage-2 builder has nothing to code-generate. The artifact is the shaken slice, executed by the shen-swift binary, the same runtime-reference relationship the
lua/juliatargets have to their toolchains. The win is boot speed: a ~200-line shaken kernel vs the full ~2500-line kernel.What's here
builders/swift/build.sh— reads the user.klfrom the manifest, copieskernel.kl+user.klnext to arunlauncher that drives shen-swift in--shakenmode (a new flag on the shen-swift side). Resolves/builds the shen-swift binary (SHEN_SWIFT/SHEN_SWIFT_BINoverridable).builders.json—swiftentry (run_impl: shen-swift,needs: ["swift"]).main.go+ratatoskr_cli.py—{shen_swift}substitution andswift → shen-swiftsibling map in both the Go CLI and the Python oracle.Load order
Mirrors the Scheme/Lua builders: load all defuns → install native overrides →
(shen.initialise)→ run the collected top-level forms (kernel, then user) so the program runs against a fully initialised environment.Verification
ratatoskr run --target swift tests/fib.shen out/→fib 20 = 6765.bifrost --shake --only recursion-fib-file --impls shen-swift,shen-lua→ both PASS, byte-identical.go vet/go test(4 passed) /pytest test_portable.py(7 passed) green.With this, all eight bifrost ports have a Ratatoskr builder.
🤖 Generated with Claude Code