Errors and Option
Vow does not have null. Absence is Option<T>; fallible work is Result<T, E>.
Hands-on: Option & Result tutorial · Syntax ergonomics.
Option
Section titled “Option”fn unwrap_or(opt: Option<int>, fallback: int) -> int { return opt ?? fallback}Or exhaustive match on Some / None:
return match caps.fs_read { Some(c) => with c { read_poc("/tmp/vow_poc.txt") }, None => 0 - 100}Some / None answer “was this grant passed at launch?” — not “did the call fail?” For failures, match Result (Ok / Err). See Option and Result tutorial.
Result
Section titled “Result”I/O builtins return Result<…, int> (integer error codes for v1).
// fragment-onlyreturn match read_file(path) { Ok(s) => len(s), Err(_) => 0 - 1}try / catch (sugar)
Section titled “try / catch (sugar)”// fragment-onlylet ok_val = try fallible(true) catch (e) { e}
try { let x = fallible(false)} catch (e) { print("caught err=", e)}? propagate
Section titled “? propagate”Propagate Err to the caller in one character when the enclosing function returns Result.
Caps fields are Option<Cap> — no grant means None.
Unused Result is an error
Section titled “Unused Result is an error”Discarding a Result without matching / try / ? is a type error.
vow check tests/lang/ignored_result.vow --jsonSugar that ships
Section titled “Sugar that ships”| Form | Example |
|---|---|
?? |
none_i ?? 99 |
?. |
Some("abc")?.len() |
try / catch |
Local Result handling |
? |
Propagate Err |