Docs/Language

Language

Syntax cheatsheet

GitHub

Compact lookup for keywords, types, and common forms.

Non-normative. Source of truth: RFC-001.

File skeleton

aura
package main

fun main() {
  println("hi")
}

Declarations

FormExample
Functionfun add(a: Int, b: Int): Int { return a + b }
Async functionasync fun load(): String { return "ok" }
Expr-body funfun double(x: Int): Int = x * 2
Localval x = 1 / var y = 2
Classclass C(var n: Int) { fun f() {} }
Structstruct S(var x: Int) {}
Interfaceinterface I { fun f(): Int }
Implementsclass C() : I { ... } / class Box<T> : I<T>
Enumenum E { case A, case B }
Generic classclass Box<T>(var v: T) {}
Generic funfun id<T>(x: T): T { return x }
Type aliastype Id = Int
Top-level constconst N: Int = 42
Test@test fun t() { assert_eq(1, 1) }
Attribute@deprecated("use newName")

Types

FormMeaning
Int Bool StringScalars
T?Nullable
Array<T>Array
Result<T, E>Success / error
(T) -> UFunction type (params → result)
T : BoundType param bound
ref TScoped non-owning reference
Task<T> / TaskHandle<T>Async result / spawned task handle
Channel<T>Bounded async FIFO channel

Lambdas (C10 + C12 captures)

aura
val f = (x: Int) => x + 1
val g: (Int) -> Int = (x: Int) => x * 2
val h = (x: Int) => {
  val y = x + 1
  return y * 2
}
// Captures: val scalar/String/class/Array/Fun; var scalar/String/class/Array/Fun
// through shared mutable boxes (C20c-e).
val base = 10
val add = (x: Int) => base + x
CaptureMVP rule
val Int / Bool / StringCopy into env (C10h)
val classGC ptr in env; env mark walks roots (C12k)
val ArrayOwned snapshot when captured; field borrows remain lexical (C12l)
var Int / Bool / String / class / Array / FunShared mutable box; lambdas share writes (C12m, C20c-e)
Captured Array ownership / live viewImmutable captures own snapshots; mutable captures use retained shared cells

Async and tasks

aura
async fun answer(): Int { return 42 }

fun main() {
  val task: TaskHandle<Int> = spawn {
    return await answer()
  }
  join(task)
  cancel(task)
}

await is valid inside async fun and spawned bodies. Channel<T>(capacity) provides bounded send, receive, and close operations. See Async, tasks & borrowing for ownership boundaries.

Attributes

Common supported forms:

aura
@test(tag = "fast")
fun testFast() { assert_eq(1, 1) }

@derive(Equals, HashCode, Debug)
struct Point(val x: Int, val y: Int) {}

@deprecated(since = "0.1.1")
fun oldApi() {}

See Attributes & derives for targets and validation rules.

Operators (common)

GroupForms
Arithmetic+ - * / %
Compare== != < <= > >=
Logic&& || !
Null?: !!
Rangea..b a..=b

Class == is identity. String content equality uses content compare in the current path; struct/enum equality is restricted in sema.

String helpers (MVP)

FormNotes
s + t / "hi ${name}"Concat; interp desugars to + (idents in ${…})
s.len / s.isEmpty()UTF-8 byte length
s.charAt(i)Byte as Int; OOB throws
s.startsWith(x) / s.contains(x) / s.endsWith(x)Substring search
s.indexOf(sub)Byte index of first match; −1 if missing; empty sub → 0 (C12f)
s.split(sep)Array<String>; empty sep throws; consecutive/trailing seps → empty segments (C12g)
s.trim() / trimStart / trimEndASCII whitespace MVP (' ', \t, \n, \r); owned copy (C12h)
s.toInt()Int?; full-string decimal; no auto-trim; optional +/-; invalid/overflow → null (C12i)
join(parts, sep)std.collections: Array<String> + sep → String; empty → "" (C12j)
s.substring(start, end)Exclusive end; UTF-8 byte indices (C11d)

No embedded NUL in strings. Indices are bytes, not Unicode scalar values.

Process I/O (std.io, C12b–e / C12p)

FormNotes
args(): Array<String>Process argv; [0] = program name; user flags from index 1 (C12b)
readLine(): String?One line without trailing newline; null on EOF (C12d)
readAllStdin(): StringRemainder of stdin (throws on oversize / error)
exit(code: Int)Terminate with status; flushes stdio (C12e)
tryReadFile(path)String? soft file read; null on missing/error (C12p)

Pass process args after --:

bash
aura run path -- flag value
aura test path --

Control

aura
if (cond) { } else if (other) { } else { }

while (cond) { break; continue }

for (i in 0..n) { }
for (i in 0..=n) { }
for (x in xs) { }

match (e) {
  case Pattern => { }
}

try { } catch (e: String) { } finally { }
throw "msg"

// scoped borrow
fun size(xs: Array<Int>): Int {
  val view: ref Array<Int> = xs
  return view.len
}

Packages & imports

aura
package app

import math
import math as M
toml
# aura.toml
[package]
name = "app"
version = "0.1.0"

[dependencies]
math = { path = "../math" }

Root procedural derive plugin:

toml
[macro_plugins]
Entity = "plugins/entity-macro"

CLI one-liners

bash
# After install (or with aura on PATH):
aura new hello && aura run hello
aura check path
aura run path
aura run path -- a b
aura build path -o out
aura test path
aura version

# In-tree monorepo:
cargo run -p aura-cli -- run path
cargo run -p aura-cli -- run examples/wc -- file.txt

Next

All docs pages