Errors and Cleanup
Flint treats errors as values.
Result and Option
The standard path for recoverable errors is Result<T, E>. Optional values use Option<T>.
This keeps error handling in the type system instead of hiding it behind exceptions.
The ? Operator
Use ? to propagate an error upward:
fn setup(bus: spi.Bus) -> Result<(), Error> {
let device = bus.init()?
device.configure()?
return ok(())
}
No Exceptions
Flint does not use exceptions, try/catch, or finally. The language prefers visible control flow and explicit propagation.
Cleanup With defer
defer is the cleanup tool:
fn setup(bus: spi.Bus) -> Result<(), Error> {
let device = bus.init()?
defer device.release()
return ok(())
}
This is especially useful for embedded and systems code where resources are often acquired and released in a tight scope.