Skip to content
📖 The Auto Programming LanguageBook contents

Appendix A: Keyword Reference ​

This appendix lists every keyword, operator, and built-in construct in the Auto language, organized by category. Each entry includes a one-line description, the chapter where it was first introduced, and a minimal usage example.


1. Declarations ​

KeywordDescriptionChapterExample
fnDefine a function or methodCh. 3fn add(a int, b int) int { a + b }
letDeclare an immutable bindingCh. 2let x = 10
varDeclare a mutable bindingCh. 2var count = 0
constDeclare a compile-time constantCh. 2const MAX_SIZE = 1024
typeDefine a custom data type (struct)Ch. 6type Point { x f64, y f64 }
enumDefine a tagged union or C-style enumCh. 7enum Color { RED = 1, GREEN = 2 }
taskDefine an actor taskCh. 15task Counter { var count int = 0 }
modDeclare a moduleCh. 10mod network { ... }
useImport a module or packageCh. 10use io
use.rustImport a Rust stdlib typeCh. 10use.rust std::collections::HashMap
importImport a specific item from a moduleCh. 10import fmt::println
pubMark an item as publicly visibleCh. 10pub fn greet() { ... }
staticMark a method as a static (type-level) methodCh. 6static fn new() Counter { ... }

2. Control Flow ​

KeywordDescriptionChapterExample
ifConditional branchCh. 3if x > 0 { print("positive") }
elseAlternate branch for ifCh. 3if ok { ... } else { ... }
isPattern matching (replaces match)Ch. 7is x { 0 => print("zero"), else => ... }
else (in is)Catch-all arm in pattern matchingCh. 7is val { _ => ... }
forIteration loop or conditional loop (replaces while)Ch. 3for i < 10 { i = i + 1 }
for ... inIterate over a collection or rangeCh. 3for item in list { print(item) }
for ... in ..Range iterationCh. 3for i in 0..10 { print(i) }
loopInfinite loopCh. 3loop { ... }
breakExit a loop earlyCh. 3if done { break }
continueSkip to the next loop iterationCh. 3if skip { continue }
returnReturn a value from a functionCh. 3return x + 1
yieldProduce a value from an iterator or generatorCh. 19yield item

3. Object-Oriented Programming ​

KeywordDescriptionChapterExample
is (in type)Single inheritanceCh. 8type Hawk is Bird { speed f64 }
hasComposition with auto-delegationCh. 8type Car has Engine { brand str }
specDefine a behavioral contract (trait)Ch. 8spec Drawable { fn draw() }
asImplement a spec for a typeCh. 8ext Circle as Drawable { ... }
extDefine methods on a type (post-hoc extension)Ch. 6ext Point { fn distance() f64 { ... } }
mut fnDeclare a method that mutates the receiverCh. 8mut fn increment() void { .count = .count + 1 }
superAccess the parent type's fields or methodsCh. 8super.fly()

4. Error Handling ​

KeywordDescriptionChapterExample
?TOptional (nullable) typeCh. 9fn find(id int) ?User { ... }
!TError-propagating result typeCh. 9fn read(path str) !str { ... }
? (operator)Propagate an error or unwrap a valueCh. 9let data = fs.read("f.txt")?
! (on fn)Mark a function as error-propagatingCh. 9fn main() ! { ... }
tryBegin a try block for exception-style error handlingCh. 9try { risky_operation() }
catchCatch an error from a try blockCh. 9catch e { print(e) }
throwRaise an error explicitlyCh. 9throw "something went wrong"
SomeConstruct an optional value with dataCh. 9Some(42)
NoneRepresent a missing optional valueCh. 9None
OkConstruct a successful resultCh. 9Ok(value)
ErrConstruct an error resultCh. 9Err("not found")

5. Concurrency ​

KeywordDescriptionChapterExample
spawnLaunch a new actor taskCh. 15let handle = spawn Counter()
sendSend a message to an actorCh. 15handle.send(Increment)
receiveReceive a message in an actorCh. 15let msg = receive
onPattern-match on incoming messages (actor mailbox)Ch. 7, 15on Increment => .count = .count + 1
selectWait on multiple async operationsCh. 16select { msg => ..., timeout => ... }
taskDefine an actor blueprintCh. 15task PingPong { ... }
~TBlueprint type (deferred / future)Ch. 16fn fetch(url str) ~str { ... }
.awaitWait for an async blueprint to resolveCh. 16let data = fetch(url).await

6. Memory & Ownership ​

KeywordDescriptionChapterExample
view TBorrow a value as read-onlyCh. 11fn print_name(v view User) { ... }
mut TBorrow a value as mutableCh. 11fn reset(m mut Counter) { m.count = 0 }
*TRaw pointer type (unsafe, sys required)Ch. 11let ptr *int = sys addr_of(x)
moveExplicitly transfer ownershipCh. 12consume(move data)
cloneCreate a deep copy of a valueCh. 12let copy = data.clone()
freeManually deallocate a valueCh. 12free(buf)
sysEnter an unsafe context (low-level access)Ch. 11sys { let p = *addr }

7. Generics ​

KeywordDescriptionChapterExample
<T>Generic type parameterCh. 13fn identity(x T) T { x }
<T, U>Multiple generic parametersCh. 13type Pair<T, U> { first T, second U }
whereConstraint clause for generic boundsCh. 13fn compare<T>(a T, b T) int where T: Ord { ... }
implSatisfy a spec bound in a where clauseCh. 13where T: impl Drawable
List<T>Generic dynamic arrayCh. 4, 13let list List<int> = List.new()
Map<K, V>Generic hash mapCh. 4, 13let m Map<str, int> = {}
Result<T, E>Generic result typeCh. 9, 13fn divide(a int, b int) Result<int, str> { ... }

8. Attributes & Metaprogramming ​

AttributeDescriptionChapterExample
#[test]Mark a function as a testCh. 18#[test] fn test_add() { ... }
#[comptime]Evaluate a function or block at compile timeCh. 20#[comptime] fn name() str { "hello" }
#[cfg(...)]Conditional compilation based on target or featureCh. 20#[cfg(target_os = "linux")] fn linux_only() { ... }
#[macro]Define a comptime macroCh. 20#[macro] fn assert_eq(a, b) { ... }
#[inline]Hint the compiler to inline a functionCh. 20#[inline] fn small_fn() int { 42 }
#[derive(...)]Auto-generate common trait implementationsCh. 20#[derive(Debug, Clone)] type Point { x f64, y f64 }

9. Literals & Built-in Types ​

Keyword / LiteralDescriptionChapterExample
trueBoolean trueCh. 2let active = true
falseBoolean falseCh. 2let done = false
nilNull / absent valueCh. 9let x ?int = nil
strString typeCh. 2let name str = "Auto"
intDefault integer type (32-bit)Ch. 2let x int = 42
f6464-bit floating-point typeCh. 2let pi f64 = 3.14
boolBoolean typeCh. 2let flag bool = true
charUnicode character typeCh. 7let c char = 'A'
voidUnit type (no meaningful value)Ch. 3fn greet() void { print("hi") }
List<T>Dynamic array typeCh. 4var items = List.new()
Map<K, V>Hash map typeCh. 4var m Map<str, int> = {}
Set<T>Hash set typeCh. 4var s Set<int> = Set.new()

10. Other ​

KeywordDescriptionChapterExample
selfAccess the current instance (via . prefix, not a parameter)Ch. 6.name (equivalent to self.name in other languages)
superReference the parent type in inheritanceCh. 8super.fly()
printPrint a value to stdoutCh. 1print("Hello, Auto!")
automanAuto's package manager and build toolCh. 1$ automan new my_project
. (field access)Access a field or call a method on a valueCh. 6point.x / list.len()
.. (range)Create a half-open rangeCh. 3for i in 0..10 { ... }
$varString interpolation (variable)Ch. 2print("Hello, $name")
${expr}String interpolation (expression)Ch. 2print("result: ${a + b}")
_Wildcard pattern (ignore a value)Ch. 7is x { _ => print("anything") }

Quick Cross-Reference: Keyword to Chapter ​

ChapterTitleKey Keywords Introduced
1Getting Startedfn, print, automan
2Variables & Operatorslet, var, const, true, false, str, int, f64, bool, $var
3Functions & Control Flowif, else, for, loop, break, continue, return, void, ..
4Collections & NodesList<T>, Map<K, V>, Set<T>
6Types & lettype, ext, static, self (implicit), tuples
7Enums & Pattern Matchingenum, is, on, char, _
8OOP Reshapedis (inheritance), has, spec, as, mut fn, super
9Error Handling?T, !T, ?, try, catch, throw, Some, None, Ok, Err
10Packages & Modulesmod, use, use.rust, import, pub
11References & Pointersview, mut, *T, sys, lifetimes
12Memory & Ownershipmove, clone, free, ownership rules
13Generics<T>, where, impl (bounds), generic types
15Actor Concurrencyspawn, send, receive, on, task, select
16Async with ~T~T, .await, async functions
17Smart Casts & Flow Typingif x is T, union types, flow-sensitive narrowing
18Testing#[test], assert_eq, assert
19Closures & Iteratorsyield, closures, .iter(), .map(), .filter(), .fold()
20Comptime & Metaprogramming#[comptime], #[cfg(...)], #[macro], #[inline], #[derive(...)]

Released under the MIT License.