AppendixExamples
Hybrid Roundtrip
A minimal example that moves execution from native to runtime and back again.
The hybrid roundtrip example is the cleanest way to see the mixed execution model.
Source shape:
@Main
@Native
function main() {
print("native main");
runtime_helper();
return;
}
@Runtime
function runtime_helper() {
print("runtime helper");
native_helper();
return;
}
@Native
function native_helper() {
print("native helper");
return;
}Run it with:
kira run --backend hybrid examples/hybrid_roundtripCurrent output:
native main
runtime helper
native helperWhat This Example Proves
- the entrypoint can be native in hybrid mode
- runtime functions stay in bytecode
- native functions compile into the shared library side
- runtime-to-native and native-to-runtime calls both work through the bridge
This is the smallest example that shows why hybrid mode exists at all.