boot: errors as values (-> T!, error(), try, or, fallible builtins and main)

A function that can fail returns { ok, value, message }. return error(...) makes
the failure; try passes it on after running the defers; 'or <value>' and
'or { ... err ... }' handle it. int(text), float(text), read_file, write_file
and delete_file report failure to an enclosing or/try instead of stopping the
program. fn main() -> ! prints the error and exits with 1.

boot.sh: 15 passed, 0 failed, 7 skipped.
This commit is contained in:
Nexoniarz 2026-10-25 18:50:29 +01:00
commit a5f417100d
5 changed files with 289 additions and 18 deletions

View file

@ -24,7 +24,7 @@ fn isHex(char c) -> bool {
fn isKeyword(str w) -> bool {
keywords := ["fn", "return", "if", "else", "while", "for", "in", "break", "continue", "true", "false",
"null", "import", "link", "struct", "defer"]
"null", "import", "link", "struct", "defer", "or", "try"]
return keywords.contains(w)
}