Skip to content

Fundamentals

Source text, values, bindings, functions, closures, operators, evaluation, and decorators.

Updated View as Markdown

These chapters introduce the forms used by almost every Atoll program.

Chapter Main question
Source How are files, tokens, comments, identifiers, and declarations written?
Literals How are scalar, text, byte, list, map, set, and aggregate values constructed?
Bindings How do immutable, mutable, annotated, and destructured locals work?
Constants Which values can be named and evaluated at compile time?
Functions How are parameters, returns, methods, generics, effects, and fallibility declared?
Closures How do anonymous functions infer types and capture their environment?
Operators What are the precedence, typing, assignment, range, and overload rules?
Evaluation In what order do expressions run, and which forms are lazy?
Decorators How does metadata attach to declarations, fields, and parameters?

Atoll is expression-oriented: blocks, conditionals, matches, and loops can produce values. Local bindings are immutable by default, type inference is local and static, and effects such as suspension are tracked by the compiler.

First program

const DEFAULT_LIMIT: int = 10

fn summarize(values: []int, limit: int = DEFAULT_LIMIT): int {
    mut total := 0
    for value in values.take(limit) {
        total += value
    }
    return total
}

fn main(): void {
    values := [2, 4, 6]
    println("total: ${summarize(values)}")
}

This small example combines a typed constant, parameter default, inferred local bindings, mutation, a collection method, iteration, assignment, interpolation, and an explicit return. Later sections explain the collection and I/O methods; the fundamentals chapters define the syntax around them.

Reading order

Read Source, Literals, Bindings, and Functions in order. Closures, Operators, and Evaluation are easiest after function values and type inference are familiar. Decorators can wait until a feature such as models, host calls, or SQL metadata requires one.

The examples in this section use the current conventions: scalar types such as int, float, bool, and string are lowercase; composite and user-defined types use PascalCase; functions and locals use snake_case.

Once these forms are familiar, continue to Control Flow for expression branching and looping, then Types for the complete static model.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close