Foreign function interface (FFI)
mu can call native libraries via dlopen, dlsym, and dlcall, or use the
higher-level ffi.fn helper for constant bindings.
Example
import "ffi"
puts := ffi.fn("/usr/lib/libSystem.B.dylib", "puts", "i32", ["cstr"])
puts("hello from mu")
Notes
- Signatures are explicit (
i8,i16,i32,i64,u8,u16,u32,u64,ptr,cstr,void). - Dynamic signatures are supported in the VM; native builds require constants.
- Errors are returned as values you can inspect.
See docs/Specification.md for full FFI rules.
Next steps
- Start with the language tour for syntax basics.
- Read the runtime guide for VM/native constraints.
- Explore the standard library modules that build on FFI.