Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Builtins

A builtin is an operation the surface does not express: machine arithmetic under the traits, string internals, and the runtime primitives under fs, args, and clock. The names below are the ones a program calls. The __ names are what the prelude and the library call, and a program reaches that behavior through the trait or the library function.

A builtin with one outcome is a function. A builtin with several outcomes is a command: the values come first, then one continuation per outcome, and exactly one continuation runs.

Strings

OperationArgumentsResult
str_lenStringi64, the number of characters
str_concatString, StringString
substringString, start i64, end i64the characters from start up to end
indexString, i64char. This is the prelude function over __index
int_to_stri64String
str_eqString, StringBool
char_to_codechari64
is_digitcharBool
is_wscharBool
skip_wsString, i64the index after the whitespace
skip_digitsString, i64the index after the digits

substring refuses a range outside the string. index refuses an index outside the string. is_ws is true when the character is Unicode whitespace. skip_ws advances over space, tab, newline, and carriage return. Add for String is concatenation, and str_concat is that operation under its own name.

Commands

OperationValuesContinuations
parse_inttext Stringok of i64, invalid of String, overflow of String
char_attext String, index i64ok of char, out_of_range of String
find_chartext String, from i64, character code i64found of i64, absent of String

index is the function that fails as a runtime error. char_at is the command that offers the miss to a continuation. find_char searches from the given index for the scalar whose code is the third argument.

Under the library

These perform IO and are reached through a hand, not called at the top of a program that wants its effects in Fs, Args, Clock, Env, Sleep, or Process.

OperationRole
__read_filefs::read, outcomes text or why
__write_filefs::write
__open_filefs::open, a File or why
__read_linefs::read_line, a line or the end
__close_filefs::close
__file_existsfs::exists
__read_dir, __dir_entryfs::read_dir. The count, then one name per index
__remove_pathfs::remove
__rename_pathfs::rename
__argument_count, __argument_atargs::arguments
__monotonic_nsclock::now
__env_get, __env_setenv::get and env::set
__sleep_nssleep::sleep
__spawn_begin, __spawn_push, __spawn_execprocess::spawn

The arithmetic builtins __add, __sub, __mul, __div, __rem, __neg, the comparisons, __sqrt, __abs, __floor, __ceil, __sin, __ln, __pow, __shl, __shr, and the __to_* conversions are the bodies of the prelude traits. __lower and __upper are string::lower and string::upper.

spawn takes a proc with main's signature, proc worker | (exit: i32) / {IO}, runs it on another host thread, and returns (,). The call performs IO. The proc's status is not a result. process::spawn is the separate operating-system child, reached through __spawn_begin, __spawn_push, and __spawn_exec.