Stdlib reference

All built-in functions, grouped by category.

Effects (recorded in effect log)

FunctionSignatureNotes
print(s: str) -> unitReplay-safe; written once even across resumes
net_fetch(url: str) -> strRecords body to log; replay does not hit network
now() -> intRecords first call; replay returns same value
random_int(lo: int, hi: int) -> intRecords; replay returns same value
read_file(path: str) -> strRecords content; file can be deleted after
write_file(path: str, content: str) -> unitReplay-safe; written once
wait_until(target_ms: int) -> unitPauses until now() >= target_ms
wait_for(name: str) -> anyPauses until pen resume --event name=val

String builtins

FunctionSignature
str_length(s: str) -> int
str_slice(s: str, start: int, end: int) -> str
to_str(x: any) -> str

List builtins

FunctionSignatureNotes
list_new(...elems) -> listVarargs
list_push(l: list, x: any) -> listReturns new list (immutable)
list_get(l: list, i: int) -> anyThrows on out-of-bounds
list_set(l: list, i: int, x: any) -> listReturns new list (immutable)
list_len(l: list) -> int

Dict builtins

FunctionSignatureNotes
dict_new() -> dictEmpty dict
dict_set(d: dict, k: str, v: any) -> dictReturns new dict (immutable)
dict_get(d: dict, k: str) -> anyThrows on missing key
dict_has(d: dict, k: str) -> bool
dict_keys(d: dict) -> list[str]Sorted

Operators

OpTypeNotes
+(int, int) → int; (str, str) → strOverloaded
- * /(int, int) → intInteger arithmetic; div truncates
< > <= >=(int, int) → bool
== !=(T, T) → boolStructural for list/dict; throws on closures