Conventions and Roadmap

Standard Library API Conventions

  • Read-only APIs use plain T parameters.
  • In-place mutation APIs use &T parameters.
  • Ownership-taking APIs use @T parameters.

Example Semantics

let @a = [1, 2, 3] // array literal: [i64; 3]
let @b = a         // copy assignment: both valid, eager copy

push(&b, 4)       // mutable borrow
len(a)            // read-only borrow

let @c <- b       // move assignment: b becomes invalid

consume(c)       // copy into owned parameter
consume(<-c)     // explicit move into owned parameter; c invalid after call
consume([9, 9, 9]) // rvalue array moves directly to matching @ type

let @head = Some(@box(Node { value: 7, next: None() }))
match (head) {
  Some(node) => log(int_to_string(node.value)),
  None() => log("empty"),
}

if (cond) {
  log(c);
}

make_value();

Behavioral guarantee: mutating one logical value never causes visible mutation of another logical value (no visible aliasing).

Implementation Phases

Phase 1: MVP Runtime

  • Type modes T, &T, @T for function parameters.
  • Required function return types.
  • Operators = and <- with defined validity rules.
  • Deterministic drop for owned values.
  • Eager copy on aggregate copy boundaries.
  • Non-null *T boxes with optionality represented as Option[*T].
  • Runtime checks for borrow and move violations.

Phase 2: Ergonomics and Performance

  • Better diagnostics.
  • Escape analysis for temporary borrow elision.
  • Small-string optimization and vector growth optimizations.
  • Reduce unnecessary temporary heap traffic.

Phase 3: Static Validation

  • Ahead-of-time validation for common move/borrow errors.
  • Earlier detection of alias/lifetime violations.
  • Optional strict mode with minimal runtime borrow checks in verified code.

Open Design Questions

  • Whether local bindings are immutable by default.
  • Whether <- is allowed in destructuring/pattern assignment for v1.
  • Which diagnostics are mandatory for MVP versus best-effort.
  • How/whether to support explicit aliases.
  • How to implement custom iterators.