FFI Preview
foreign func is the native trust boundary for calling C-compatible symbols.
Foreign Func
An impure foreign func can call native code and is not callable from pure functions.
ffi.brp
foreign func c_add(a: Int, b: Int) -> Int = "add_ints"C ABI
Blorp can bind functions exported with a C-compatible ABI.
c-abi.h
int add_ints(int a, int b);Purity/safety Modes
foreign pure func is for side-effect-free native code; @no_copy skips defensive copies only when you can prove the C side will not mutate or retain data.
ffi-safe.brp
foreign pure func c_abs(n: Int) -> Int = "abs"Package Boundary
Keep FFI declarations in explicit user or package modules so unsafe edges stay easy to audit.
import-pkg.brp
import:
pkg/math/native as NativeExample
ffi-add.brp
foreign:
pure func add_ints(a: Int, b: Int) -> Int
pure func total(a: Int, b: Int) -> Int:
add_ints(a, b)
func main(args: List[String]) -> Void:
print(total(20, 22).to_string())
Try It
terminal
blorp check ffi-add.brp