Skip to content

Builtins

A builtin is a type or function that the Beans compiler knows about on its own. You do not import it. You do not write it. It is always there, ready to use. The int type, the string type, List, Option, and the panic function are all builtins.

This page lists every builtin and links to a page that explains it in full.

Beans builds its builtins in two ways. You do not need to think about this while you write code, but it helps to know it once.

  • Some builtins are written in C++ and reached through a fixed runtime table (the “runtime ABI”). These are string, Bytes, File, MMap, and the std.* modules that talk to the operating system. You can see the table at compiler/beans/expression.b.
  • The rest are written into the compiler’s own type checker and turned into machine code by the code generator. These are the generic types (List, Map, Box, Atomic, RawPtr, Slice, SIMD) and compile-time helpers like size_of. You can see the checker at compiler/beans/expression.b.

The runtime ABI version for this compiler is 6. The compiler reports version 0.1.18 and the language contract is frozen at 1.0.

Beans has no null and no exceptions. Instead it gives you three builtin types for “maybe” and “failed” answers, and you will see them all over this reference:

  • Option<T>: a value that may be missing.
  • Result<T, E>: a value or an error.
  • Error: the standard error class.

These, and the collection types like List and Map, are all builtin. Read Option, Result, and Error for the full story.

PageWhat it covers
Primitive typesunit, bool, the integer and float types, byte, string
Numbers and decimalnumber rules, casts with as, and exact decimal math
stringthe string type and every method on it
Bytesthe growable byte buffer Bytes
CollectionsList, Map, and OrderedMap
Option, Result, and ErrorOption, Result, Error, some/none/ok/err, the ? operator
Ownership handlesBox, Arena, Shared, Weak, Mutex, Channel, Thread, AtomicInt
AtomicsAtomic<T> and MemoryOrder
Files and mappingFile, Dir, MMap
SIMD, arrays, and pointersSimd{N}{elem}, [T; N], Slice<T>, RawPtr<T>
Prelude functionspanic, size_of/align_of/offset_of, printing