More language features

Beyond the core pages, Lumina has a layer of annotation-driven features: checks the compiler enforces, memory control, proxies, custom literals and testing helpers. Most sit behind an import or an annotation, so a program that does not use them never pays for them. Each claim carries a badge; Status & Roadmap says exactly where each stands, and Language_Annotations.md is the canonical annotation index.

Contracts

@Contract.requires and @Contract.ensures state what a function expects and promises. A violation the compiler can prove (a literal argument) is rejected with E4011; otherwise it becomes a runtime panic. Contracts work on parameters, functions and struct fields in progress, but compound clauses such as a > 0 && a < 10 and struct-level invariants are accepted without being enforced. Spec: Language_Advanced_Contracts.md.

import from "std/contracts"

@Contract.ensures(result >= 0)
function abs(x: Integer): Integer = if x < 0 { -x } else { x }

function divide(a: Integer, b @Contract.requires(b != 0): Integer): Integer = a / b

function main(): Integer {
    print(divide(10, 2))
    return abs(-5)
}

Calling divide(1, 0) with literals fails to compile; with values known only at run time it panics with contract violated: requires b != 0.

Panics and defer

panic(message) stops the program with exit code 134, and the panicking function's @Defer blocks run first implemented. Unwinding through callers, @PanicBoundary and recovering from a panic are designed, and the compiler rejects them loudly today designed. Spec: Language_Advanced_Panics.md.

Memory zones

@Zone(4096) gives a function a bump-allocation budget, and a zone value that would escape to a global is a compile error in progress. Overflowing the budget falls back to the heap silently; a hard limit and the budget DSL do not exist yet. Specs: Language_Memory.md, Language_GC.md.

struct Point {
    x: Integer
    y: Integer
}

@Zone(4096)
function zoneCompute(): Integer {
    p1 = Point(x: 10, y: 20)
    p2 = Point(x: 5, y: 7)
    return p1.x + p1.y + p2.x + p2.y
}

function main(): Integer = zoneCompute()

Type forwarding

A @Forward struct wraps another type and intercepts every method call in one place, so logging, caching, mocking and stubbing need no per-method boilerplate. The Logged, Stub, Cached and Mock proxies work implemented; a Remote proxy is only designed designed. Spec: Language_TypeForwarding.md.

@Forward
struct Logged<T> {
    inner: T

    function mapCall<R>(self, call: Call<T, R>): R {
        println(call.name)
        return call.invoke(self.inner)
    }
}

Wrap a value with Logged(inner: User(name: "Alice")) and call greet on it as if it were the User; mapCall sees every call.

Typed literals

@Literal turns a suffix or prefix into a constructor call, so units and formats become types instead of bare numbers implemented. Checking a literal's value at compile time is only designed designed. Built-in suffixes such as 500ms and 2GB produce plain integers (nanoseconds and bytes). Spec: Language_TypedLiterals.md.

@Literal(suffix: "km")
struct Distance {
    public meters: Integer
    public static function fromLiteral(value: Integer): Distance = Distance(meters: value * 1000)
    public function toKm(self): Integer = self.meters / 1000
}

function main(): Integer {
    d = 42km
    println(`{d.toKm()}`)
    return 0
}

Dialect-checked strings

A tag in front of a backtick literal names a dialect the compiler validates: json[1, 2,]fails with E1112 for the trailing comma. Built-in dialects and user-written validators work [MOSTLY-DONE](status-and-roadmap.md#string-dialect). TheStringTemplatetype does not exist yet [DESIGNED-NOT-IMPLEMENTED](status-and-roadmap.md#string-template). Spec:Language_StringTemplate.md`.

Test annotations

@Skip, @BeforeEach, @AfterEach and @Timeout work under lumina test implemented; @Timeout limits CPU time, not wall-clock time. @Fuzz and @Expect are accepted but inert designed. Spec: Language_Testing.md.

@Test
function adds() {
    assert(1 + 1 == 2)
}

@Test
@Skip
function notYet() {
    assert(false)
}

@Test
@Timeout(1000)
function finishesInTime() {
    assert(2 * 2 == 4)
}

Function wrappers

@Cache(60) caches a free function's results implemented. @Logged, @Memoize and @Retry on ordinary functions are accepted but have no effect in progress. User annotations are an @Annotation interface plus an @AnnotationHandler (behind import from "lumina.meta"); the transform handler API with ctx.wrap is the planned way to build @Logged, @Retry and auth checks in progress. The old @Decorator marker is deprecated.

Sandboxed modules

Module.loadSource compiles and runs untrusted source in a restricted module, @Sandbox marks sandboxed functions, and ResourceLimits caps CPU and memory in progress. Module.load(path) is missing. @Trusted and @FullAccess are not sandbox tiers: they gate @ExternC and view narrowing. Spec: Language_Agents.md.

And more

Next: Built for Agents