Basics
Use case: a tiny exit-code program
Section titled “Use case: a tiny exit-code program”Every Vow program starts the same way:
fn main(caps: Caps) -> int { return 1 + 2}From a vow new project (file is src/main.vow):
vow build src/main.vow -o app./appecho $? # 3Or vow run src/main.vow. For a single file named hello.vow, use vow build hello.vow -o hello instead.
Capabilities always enter through caps — even when unused.
Bindings
Section titled “Bindings”| Keyword | Meaning |
|---|---|
let |
Immutable binding |
var |
Mutable binding |
| Parameters | Always immutable |
fn main(caps: Caps) -> int { let greeting = "hello" var count = 0 count = count + 1 count += 1 print greeting, count return count}Compound assign: += -= *= /=. Statement-only i++ / i-- (not x = i++).
Types you will use daily
Section titled “Types you will use daily”| Write | Notes |
|---|---|
int, int64 |
No implicit mix — cast with as |
f32, f64 |
Float literals default to f64 |
bool |
true / false |
String |
Heap string |
Array<T> |
Not List |
Map<String, V> |
String keys only (v1) |
Option<T>, Result<T, E> |
Prelude — no null |
Aliases the compiler accepts: i32→int, i64→int64, string→String, float/double→f64. Prefer the canonical names in new code.
type Score = int
fn main(caps: Caps) -> int { let s: Score = 42 let wide = s as int64 return s}Comments and literals
Section titled “Comments and literals”// line comments only — no /* block */ yetlet n = 42let pi = 3.14let ok = truelet name = "Ada"let nums = [1, 2, 3]Semicolons are optional in most places (phase4_syntax.vow). Keep them if you prefer; vow fmt will not invent a second style fight for you.
function vs fn
Section titled “function vs fn”Top-level function is an alias of fn. Methods and interface methods use fn only. vow fmt normalizes function → fn.
function bump(x: int) -> int { return x + 1}Ambient print
Section titled “Ambient print”// fragment-onlyprint 1, true, "ok"eprint "debug:", 0