Appearance
Builtins reference
Tantu's builtins are callable names available in every program, with no import needed. A few (chan, send, recv, close, sleep, print) are compiler intrinsics backed by dedicated bytecode; the rest are ordinary library functions. Referencing a builtin outside call position is a compile error; they aren't first-class values.
In the signatures below, T and U stand for any type.
| Name | Signature | Notes |
|---|---|---|
print | (T) -> Unit | any value; prints via the PRINT op |
str | (T) -> Str | render to a string (a Str is returned unquoted) |
len | (List[T]) -> Int, (Str) -> Int | length; two overloads |
push | (List[T], T) -> List[T] | returns a NEW list (lists are immutable by convention) |
get | (List[T], Int) -> Option[T] | safe index; None when out of range |
concat | (List[T], List[T]) -> List[T] | join two lists |
range | (Int, Int) -> List[Int] | half-open [a, b) |
float | (Int) -> Float | widen an Int |
trunc | (Float) -> Int | truncate toward zero |
parse_int | (Str) -> Option[Int] | None if not an integer |
split | (Str, Str) -> List[Str] | split on a separator |
substring | (Str, Int, Int) -> Str | half-open, clamps to bounds |
chars | (Str) -> List[Str] | explode into single-character strings |
chan[T](n?) | () -> Chan[T] / (Int) -> Chan[T] | make a channel (optional buffer size) |
send | (Chan[T], T) -> Unit | send a value (blocks when full) |
recv | (Chan[T]) -> Option[T] | receive; None when the channel is closed + drained |
close | (Chan[T]) -> Unit | close a channel |
sleep | (Int) -> Unit | yield for N milliseconds |
Generated
This table is generated from the language's builtin registry (tantu/prelude.py) and Appendix A of the design spec, so it stays in sync with the interpreter.
See Types & no-null for how Option and Result (returned by get, parse_int, and recv) are consumed, and Collections for lists, tuples, and strings.