Skip to content

Common Patterns

Make State Explicit

Use var for mutable state and const for stable values.

const MAX_RETRIES: int = 3
var retry_count: int = 0

Keep Branches Small

if ready {
    print("go")
} else {
    print("wait")
}

Prefer Named Construction

record User {
    name: str
    age: int
}

const user = User {
    name: "Ava"
    age: 31
}

Use Explicit Errors

func parse_count(text: str) -> int throws ParseError {
    raise ParseError {
        message: "bad count"
    }
}