Lowent Manual←↑→

Appendix A — Words and builtins

The text is where words are explained. This appendix gathers only tables to skim when you get stuck reading code. The word list is the same as the specification’s Appendix A, and anything not in that list is not a word.

The forty-three words#

KindWordsChapter
Declarationsmodule use type newtype struct enum trait contract actor statechapters 21 and 13
opsfn proc export unsafe extern satisfieschapter 5
Localslet var set bechapter 6
Flowif else while for guard match case return break continue trychapter 7
Expressions and valuesexpr make true false nonechapter 8
Concurrencyspawn sendchapter 25
Ownershipdropchapter 19
Teststest expectchapter 31
Blocksdo endchapter 3

Table 50.1 — All the words

rem and note are markers opening comments, and clause heads such as input, output, effects and requires and builtins such as add and len are not words but cannot be used as names.

Removed words#

RemovedInstead
loopwhile true .
givereturn
unitvoid
calcop · procopfn · proc
is · as (in declarations) · localNot written
to · in (field access)field a b · index a i
onproc inside an actor
failreturn error <variant>
; · ,.

Table 50.2 — Removed words and what to use instead (E-VOCAB-REMOVED)

as and to remain only as position markers in use … as <alias> and case <low> to <high>.

Frequently used builtins#

KindOperations
Arithmetic (stopping)add sub mul div mod neg abs min max
Arithmetic (choosing the outcome)wrap_* sat_* chk_* div_nz nonzero_of
Changing widthwiden narrow narrow_wrap narrow_sat narrow_try cast bit_cast
Comparison and logiceq ne lt le gt ge and or not
Bitsbit_and bit_or bit_xor bit_not shl shr rotl rotr wrap_shl wrap_shr count_ones leading_zeros trailing_zeros byte_swap clmul_lo clmul_hi
Sequenceslen index subslice view view_array same_slice
Groupingsfield method isa get
Answer-carrying typessome ok error is_some is_none is_ok is_error some_value ok_value error_value value_or
Translation timesize_of comptime config
Allocationalloc_bytes
I/O leaveswrite_out read_in arg · file, connection, clock, random and terminal leaves are wrapped by the standard library
Atomicatomic_load atomic_store atomic_add atomic_sub atomic_swap atomic_cas atomic_fence
Devicesread_volatile write_volatile
Concurrencyawait drain channel chsend chrecv yield spawn send
Atomic (bits)atomic_and atomic_or atomic_xor
Floating-point maths — chapter 4sqrt sin cos exp log pow floor ceil round fmod sum_neumaier sum_seq
Pipe stages — chapter 24pipe map filter fold scan take skip zip enumerate reverse collect count all any into
Lanes (SIMD) — chapter 27splat load store load_masked store_masked select reduce_add reduce_mul reduce_min reduce_max avg native_lanes rotate prefetch
Small-number sets — chapter 13bitset_new union intersect difference complement contains is_subset is_empty remove
Layouts and views — chapter 13encode try_view view_segments seg segs capacity
Borrows and regions — chapter 12 · chapter 18ref mut_ref deref borrow region stack_new push pop swap
Contracts and errors — chapter 14range ret expect panic
Computation leaves — stand only after call_builtinclmul_lo clmul_hi aes_round aes_round_last aes_ctr ghash chacha20 poly1305 aes_gcm chacha_poly sha256 sha384 sha512 crc32 hash_bytes rng_next
C strings — chapter 29cstr_of str_from_cstr
Host leaves — chapter 32file_open file_read file_write file_seek file_close file_type link_type dir_open dir_read dir_close dir_make path_remove path_rename net_listen net_accept net_connect net_resolve net_send net_recv net_close net_pair net_port env_get reactor_new r_read r_write

Table 50.3 — Kinds of builtins

★ The fifteen computation leaves are not global words. They stand only in that position — call_builtin sha256 msg out. Calling one bare is E-BUILTIN-BARE; naming something else after call_builtin is E-BUILTIN-NAME. The reason is one: a word a program uses once should not cost every reader a name to remember. The same rule already governs the stage names inside pipe and the type slot of cast u8 x.

This table sorts every builtin of the canon into a group. The chapter next to each group name explains that group with examples. The one-line meanings are authoritative in the repository’s docs/spec/BUILTIN-MEANINGS.tsv.

Effects and capabilities#

EffectPermitting capabilityChapter
iocap io · file_system · net · tty · clock · randomchapter 16
alloc · heapcap allocator · cap heapchapters 18 and 20
atomiccap atomicchapter 27
devicecap mmiochapter 30
unsafecap c · cap machine (depending on use)chapters 29 and 30
state · panic · wait · concurrentWritten without capabilitieschapters 15 and 26

Table 50.4 — Effect atoms and their paired capabilities