Literals construct values directly in source. Their final type is determined by the literal form and, where permitted, by the surrounding expected type.
Booleans
The boolean literals are true and false, both of type bool.
enabled := true
visible: bool = falseAtoll has no truthiness conversion. Conditions require bool; integers,
strings, lists, and optional values are not conditions by themselves.
Integers
Integer literals can be decimal, hexadecimal, binary, or octal. Underscores may separate digits for readability.
decimal := 1_000_000
mask := 0xFF
flags := 0b1010_0011
permissions := 0o755An unsuffixed integer uses its expected numeric type when one is available.
Otherwise it defaults to int.
small: u8 = 200
ordinary := 200 // intA suffix fixes the literal type. Current suffixes include i8, i16, i32,
i64, u8, u16, u32, u64, isize, and usize.
port := 8080u16
byte_value := 255u8
offset := 32isizeThe compiler diagnoses a value that does not fit its suffix or contextual type. A suffix does not truncate the value.
Floating points
Floating-point literals contain a decimal point or exponent and default to
float. The f32 and f64 suffixes select a fixed-width type.
ratio := 0.625
scientific := 6.022e23
compact := 1.5f32
precise := 1.25f64Integer and floating-point literals do not silently cross categories merely because their mathematical values happen to be equal. Use an explicit cast where conversion is intended.
Characters
Single quotes construct a char.
letter := 'A'
newline := '\n'
heart := '\u{2764}'Character escapes include the common control escapes and Unicode scalar escapes. A character literal must resolve to one character value.
Strings
Double quotes construct a UTF-8 string. Escapes are processed, and $name
or ${expression} inserts a value using its display operation.
name := "Ada"
sum := 2 + 3
message := "Hello, $name; 2 + 3 = ${sum}"
escaped := "line one\nline two"Use \$ for a literal dollar sign. A braced interpolation may contain a full
expression, including calls and member access.
report := "total: ${items.len()}, first: ${items[0]}"Triple-quoted strings are useful for multi-line text. They support interpolation and remove indentation shared with the closing delimiter.
message := """
first line
indented line
value: ${sum}
"""Raw strings use r"...". They perform neither escape processing nor
interpolation.
pattern := r"\d+\.\d+"
dollars := r"$HOME is not interpolated"String storage, slicing, iteration, and Unicode boundaries are documented in Strings.
Byte strings
A byte string uses b"..." and produces []byte.
signature := b"\x89PNG"
header: []byte = b"ATOLL"Byte strings accept ASCII source bytes and byte escapes such as \xFF.
Non-ASCII source characters are rejected because one visible character need
not correspond to one byte. Use a normal string followed by explicit UTF-8
encoding when Unicode text must become bytes.
Sequences
Square brackets construct a list. The element type is inferred from the elements or the expected type.
numbers := [1, 2, 3]
names: []string = []An empty list needs context. A fixed array uses the same value syntax but is selected by a fixed-array expected type.
magic: [4]byte = [0x7F, 0x45, 0x4C, 0x46]Maps and sets currently use prelude constructors rather than brace-only literals.
mut ports: Map[string, int] = Map.new()
mut tags: Set[string] = Set.new()Tuples
Parenthesized comma-separated expressions construct a tuple. () is the unit
value.
pair := ("port", 8080)
triple := (1, true, "ready")
empty := ()A comma is what makes a tuple; ordinary parentheses only group an expression.
Structs
A nominal type followed by named fields constructs a struct or a struct-style enum variant.
point := Point { x: 10, y: 20 }
error := ParseError.InvalidDigit { position: 4 }Field shorthand is accepted when a visible binding has the same name.
x := 10
y := 20
point := Point { x, y }Anonymous records use a brace form in expression contexts where the parser can distinguish the fields from a statement block. Their structural type is covered in Records.