Overview of Bolt
mainBolt is a lightweight, lightning-fast, type-safe embeddable language designed for real-time applications. It features an embed-first design that prioritizes inter-language performance and agility, making it suitable for integration into existing host applications with minimal overhead.
import print, error, Error from core
import abs, epsilon from math
// The return type of safe_divide is inferred to be `Error | number`
fn safe_divide(a: number, b: number) {
if abs(b) < epsilon {
return error("Cannot divide by zero!")
}
return a / b
}
match let result = safe_divide(10, 5) {
is Error {
// The type of result is narrowed in this branch!
print("Failed to divide:", result.what)
}
is number {
print("The answer is", result)
}
}