Skip to content

Built-in functions

There is a Phase 1 builtin surface (pure helpers + Clock-gated time) plus optional modules under the compiler’s stdlib/ search path (json.vow, collections.vow, math.vow, http.vow, …). App libraries install with vpm.

Prefer the use-case walkthrough first: Built-in functions tutorial.

Smoke test:

Terminal window
vow run tests/lang/phase1_stdlib.vow -- --grant clock:
Function Notes
str_trim / str_replace / str_split / str_join Trim, replace-all, split, join
str_find / str_slice Search / substring
str_to_upper / str_to_lower (aliases to_upper / to_lower) ASCII case
str_starts_with / str_ends_with / str_contains Prefix / suffix / substring
parse_int / parse_float Result<…, int>
to_string_int / to_string_i64 / to_string_f64 / to_string_bool Formatting
str_repeat / str_pad Repeat / left-pad
len / .len() Length
Function Notes
array_push / array_pop Grow / shrink
array_sort / array_reverse In-place on Array<int> today
array_contains / array_index_of Membership (-1 if missing)
array_map / array_filter Higher-order (fn values / lambdas)
map_new / map_get / map_set / len Map<String, V> only (v1)
map_keys / map_contains_key / map_remove Key listing / membership / remove

Index assign (xs[i] = x) and struct field assign ship on var bindings.

abs_int / abs_i64 / abs_f64, min_int / max_int / min_f64 / max_f64, pow_f64, sqrt_f64, floor_f64, ceil_f64, round_f64.

JsonValue is a dynamic JSON tree — like values from JSON.parse in JavaScript. Import:

import json
API Notes
json.parse / json.stringify Round-trip strings
{ title: "hi", n: 1 } Object literal
[1, "two", true] Array literal (use JsonValue annotation for object arrays)
doc.title / doc["title"] / arr[0] Read
obj.title = "x" / obj["n"] = 42 Write (primitives auto-wrap)
json.get_string(obj, "title", default) Key lookup with default
json.string_or / int_or / bool_or Coerce with default

Full guide: JSON tutorial. Demo: hello-app.

Low-level builtins: json_parse, json_stringify, json_get, json_set, json_push, json_as_string, …

API Capability Notes
read_file FsRead Result<String, int>
write_file FsWrite Result<int, int>
file_mtime FsRead Epoch seconds (poll-based)
net_get / http_get Net Host / HTTP get
http_serve_once / http_accept_once / http_reply_once Net Loopback bind by default
http_read_body / http_header (request context) See stdlib/http.vow
env_get Env
clock_now / clock_sleep Clock Unix ms / sleep ms
rand_next Rand
thread_spawn / thread_join Threads Named fn() -> int workers
process_spawn / process_wait Proc
db_connect Db Stub connect — --grant db:…
log_write Log Append — --grant log:sink_path

Grant flags: fs-read:, fs-write:, net: (optional net::PORT / net:*:PORT), env:, clock:, rand:, threads, proc:, db:, log:.

Attenuation: .scoped_to(…) on cap values (FS limit_to remains an alias). Manifests: vow run … --manifest vow.grants.toml.

HTTP routing for apps lives in vow-web-server. Use block_on inside sync handlers for async DB/file work — see Async / await.

Builtin Caps Notes
db_query(handle, sql) Db (via handle) Returns JSON rows string; use with await + ?
read_file_async(path) FsRead await in async fn
async_sleep(ms) Clock Scheduler timer
spawn_blocking(fn) Offload no-arg fn() -> int
async_spawn(fn) Fire-and-forget child
block_on(async_fn) Sync only — run async fn to completion
block_on(async_fn, args…) Pass parameters to async fn
// fragment-only
print("a=", 1, true)
eprint("debug:", x)

No grant. Not part of the Caps I/O model.

  • Generic Map<K, V> for non-string keys (partial — some key types work)
  • Network client async await
  • async fn HTTP handlers (use sync handlers + block_on today)
  • inotify / FS events (use file_mtime polling)
  • FFI
  • Mature package ecosystem — see Package ecosystem