Global builtins
no importAlways available, no import. Defined natively in src/builtins.odin. format uses {} placeholders only (no format specifiers). For newline-terminated and separator-aware printing, use the prelude wrappers (println, printf, …) below.
Output
print(..any)
Write each argument's string form to stdout, no separator, no trailing newline.
eprint(..any)
Same as print but writes to stderr (diagnostics; keeps stdout clean for program data).
format(fmt: string, ..any) => string
Substitute each {} in fmt with the next argument's string form; returns the result. Extra {} with no argument are dropped; extra args are ignored.
Collections
len(x) => int
Length of a string (in codepoints), list, or map.
append(list: [T], v: T) => [T]
Append v to list in place (lists are reference types) and return it.
delete(coll, key)
Remove by index from a list, or by key from a map. Errors on out-of-bounds list index.
has(coll, key) => bool
Membership test: for a map, is key present; for a list, is key an element. This is the primitive behind "is X in Y" (Zinc has no in operator).
contains(coll, value) => bool
Value membership: does the list/map hold value (searches map values, not keys — use has for keys).
keys(map: [K, V]) => [K]
New list of the map's keys, in insertion order.
values(map: [K, V]) => [V]
New list of the map's values, in insertion order.
range(end) / range(start, end) / range(start, end, step) => [int]
Build a list of ints. One arg → [0, end); two → [start, end); three adds a step (may be negative; zero is an error).
Types and conversion
type_of(v) => string
Runtime type name: "nil", "int", "float", "bool", "char", "string", "list", "map", "function", "module", "struct", "enum", or a struct/enum's own name for instances. ("iterator" is a reserved tag in the extension ABI but no Zinc value can have it today — see src/value.odin's note on Object_Kind.Iterator.)
string(v) => string
Convert any value to its string representation. Also the int↔string / float↔string cast form.
Failure
panic(msg?)
Deliberate abort: unwinds to the top with a stack trace and exit code 70. For "this should never happen".
assert(cond, msg?)
Abort loudly (like panic) when cond is falsy. Optional message. Pairs with panic for invariants; use the (value, err) model for recoverable errors.