docs / reference
Reference (0.7 surface)
Compact lookup for everyday fx in the 0.7.1 package. Prefer the language tour when learning. This page describes the language as implemented, not aspirational north-star ideas.
Keywords
enum struct extern fn import
let match module return effects
if while for break continue
else defer region arena scope
temp fx own mut true
false using · plus ok / err constructors in Result paths.
Comments: // line comments. Refinement where is contextual (verification tier).
Literals
- Integers: decimal
123, hex0x1F(underscores allowed) - Floats:
1.5(defaultsf64),1.5f32 - Chars:
'A','\n'(lower toi32byte values) - Strings:
"…"with standard escapes · bools:true/false
Program shape
- File: module library (
module name;) or program withfn main - Entry: usually
fn main() -> i32; may returnResult<i32, core_Err> - Imports:
import std/vec;(path; last segment = alias; no transitive visibility) - Zspec into scope:
using core;/using core.mem; - FFI:
extern "c" { fn name(args) -> ret; }
Types
| Kind | Forms |
|---|---|
| Integers | i8 i16 i32 i64 u8 u16 u32 u64 |
| Floats | f32 f64 |
| Scalars | bool string void core_Err |
| User types | struct Name { … } · enum Name { A, B(T) } |
| Collections | Vec<T> · [T; N] · &[T] · StrBuilder · Map<string, i32> |
| Sum | Result<T, E> |
| Ownership | own T · &T · &mut T · ®ion r T |
| Generics | Type params on functions/structs · no traits |
Vec<T> elements commonly used: integers (incl. unsigned widths), bool,
string, structs, payload enums. Casts: expr as T for numeric targets only.
Effects
fn f() -> i32 effects { alloc, mut, io } { … }
| Effect | Meaning |
|---|---|
alloc | Heap / arena allocation |
mut | Mutation of heap / exclusive borrows as required |
io | Host I/O (stdout, files, …) |
Regions
| Syntax | Role |
|---|---|
region r = arena(n); | Default heap arena |
region r = temp(n); | Short-lived heap batch |
region r = scope; | Stack borrow region (no heap) |
region r = fx(n); | Hierarchical fx region |
Details: Regions and effects
Operators
- Arithmetic:
+ - * / %(integers;%int-only) ·+ - * /(floats) · unary- - Bitwise:
& | ^ << >>on integer families - Logical:
!&&||(bool) - Compare:
== != < <= > >= - Index:
a[i]on arrays (R/W) and slices (read-only) - Cast:
expr as T· deref:*p
No v[i] on Vec; use vec_get / facade vec.get.
Statements
let x: T = expr;· reassignment ·returnif/else·while·for (let i = …; …; …)break/continue·defer stmt;·matchregion r = …;
Result / ?
- Construct:
Ok(x)/Err(e)(typically withusing core;) - Propagate:
let x = f()?;andx = f()?; - No
Option; useResult
Builtins vs std facades
| Area | Builtins (common) | std facade |
|---|---|---|
| Vec | vec_new vec_push vec_get · .len | std/vec (new/push/get/len) |
| String | str_compare str_concat str_len str_byte_at | std/string |
| Builder | strbuf_new strbuf_push strbuf_finish strbuf_len | builder/append/build |
| Map | map_new map_insert map_get map_contains … | std/map · set via std/set |
| Fmt / IO | (via facades) | std/fmt · std/io |
Growing ops are value-threaded: reassign
v = vec_push(v, x), m = map_insert(m, k, v), b = strbuf_push(b, s).
Scaffolds
| Kind | Use when |
|---|---|
simple | Default: region + std/vec |
minimal | Bare main; add region yourself |
embedded | Tiny arena; builtin vec_*; no staged std |
Honesty bound (not in 0.7 yet)
- Traits, closures, iterators,
Option Vecoperator index; nestedVec<Vec<T>>;Vec<f32>etc.- Generic maps beyond
string → i32; map iteration &mut [T], subrange slices- Package manager; advanced fx Runtime device/capability model
- Non-C FFI
Advanced: refinement types (where predicates) exist as a verification tier and typically need an
external prover pipeline. Not required for everyday 0.7 programs.