Builtins
The functions that come with the language.
Builtins are functions you can use without writing them yourself. The 4.0 compiler knows 301 of them, up from 74 in 3.9. This page lists the ones the kit tests on your machine.
Text and files
| Builtin | What it does |
|---|---|
| Write a value, one per line | |
| len, char_at, concat | Measure, read and join text |
| str_slice | A piece of a string |
| read_file, write_file, read_bytes | Files |
| out_capture, out_take | Capture what a program prints |
| str_hex, str_unhex, str_byte, str_xor | Byte helpers |
| str_sum, str_bytes, str_words, words_str | Measurements and conversions |
Math
| Builtin | What it does |
|---|---|
| abs, floor, sqrt | Absolute value, round down, square root |
| max, min, mod | Larger, smaller, remainder (mod by 0 is 0) |
System cell operations
Inside a system cell, these work in the cell's own type, the one after its ->.
| Group | Operations |
|---|---|
| Arithmetic and compare | iadd isub imul idiv imod iand ior ixor ishl ishr ieq ine ilt ile igt ige ineg |
| Logic and shifts (float cells too) | band, bor, bxor, shl, shr |
| Typed memory | load8 to load64(p), store8 to store64(p, v) |
| Conversions | to_u64, to_i64 |
Roles
A cell can take on a job with cell assign. Each job comes with its own builtins:
| Role | Builtins |
|---|---|
| Stems | differentiate, undifferentiate |
| Taggers and pruners | tag_NAME, prune_NAME |
| Immune guards | awaken_NAME, summon_NAME, patrol, quarantine |
| Tasks | run_all, kill, task_state, task_steps, sleep_ticks, wait_key |
Inside Sanguix
The compiler also knows the builtins that Sanguix, our operating system, provides. They cover graphics, WebAssembly, encryption, devices and memory, the web engine, pictures and erasure codes. Use a hardware one outside Sanguix and you get an error that names it.