Built-in functions
Vow ships a builtin surface — call these without importing a package. Full tables live in the Built-in functions reference. App libraries (HTTP, etc.) come from vpm.
vow run tests/lang/phase1_stdlib.vow -- --grant clock:Use case: string helpers
Section titled “Use case: string helpers”fn main(caps: Caps) -> int { assert str_to_upper("hi") == "HI"; assert str_contains("hello", "ell") == true; assert str_starts_with("hello", "hel") == true; let n = match parse_int("42") { Ok(v) => v, Err(_e) => 0 } print(str_join(["a", "b"], "-")) print(to_string_int(n)) return n}Also: str_trim, str_replace, str_split, str_to_lower, str_ends_with, str_repeat, str_pad,
str_find, str_slice, parse_float, to_string_*.
Use case: arrays and maps
Section titled “Use case: arrays and maps”// fragment-onlyfn main(caps: Caps) -> int { var xs = [3, 1, 2] xs = array_push(xs, 4) xs = array_pop(xs) xs = array_sort(xs) assert xs[0] == 1; assert array_contains(xs, 2) == true;
let evens = array_filter(xs, (x) -> x % 2 == 0) let doubled = array_map(evens, (x: int) -> x * 2)
var m: Map<String, int> = map_new() m = map_set(m, "a", 1) assert map_contains_key(m, "a") == true; print map_keys(m) print doubled return len(xs)}v1 maps are Map<String, V> only.
Use case: math
Section titled “Use case: math”fn main(caps: Caps) -> int { assert abs_int(-5) == 5; assert min_int(1, 9) == 1; assert max_int(1, 9) == 9; assert sqrt_f64(4.0) == 2.0; return 0}Also: abs_i64 / abs_f64, min_f64 / max_f64, pow_f64, floor_f64, ceil_f64, round_f64.
Use case: JSON round-trip
Section titled “Use case: JSON round-trip”// fragment-onlyfn main(caps: Caps) -> int { let parsed = json_parse("{\"n\":42}") return match parsed { Ok(v) => { print json_stringify(v); return 0; }, Err(_) => 0 - 1 }}JsonValue is opaque — json_parse / json_stringify / json_free. No Caps required.
Use case: debug print
Section titled “Use case: debug print”fn main(caps: Caps) -> int { print("a=", 1, true) eprint("debug:", 2) return 0}Ambient — no Caps grant. Not part of the capability I/O model.
Use case: effectful I/O (needs a grant)
Section titled “Use case: effectful I/O (needs a grant)”| Builtin | Cap | Grant example |
|---|---|---|
read_file / file_mtime |
FsRead |
--grant fs-read:/tmp |
write_file |
FsWrite |
--grant fs-write:/tmp |
net_get / http_get |
Net |
--grant net:example.com |
env_get |
Env |
--grant env:HOME |
clock_now / clock_sleep |
Clock |
--grant clock: |
rand_next |
Rand |
--grant rand: |
thread_spawn / thread_join |
Threads |
--grant threads |
process_spawn / process_wait |
Proc |
--grant proc: |
db_connect |
Db |
--grant db:… (stub) |
log_write |
Log |
--grant log:/tmp/app.log |
vow run app.vow -- --grant fs-read:/data --grant clock:HTTP routing is not a builtin — use vow-web-server.