Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / learn v0.1.0-demo.2

    Language overview

    Xen compiles programs to static Linux executables. Its language includes functions, structs, enums, generics, and type-dependent copy and move semantics. Explicit references and block optimization are controlled by scope annotations.

    Declare a value with let, or let mut when it will change. Simple values such as integers and booleans copy. Strings and vectors with cloneable elements produce independent copies. Box and File transfer ownership. The same copy behavior does not apply to every type.

    fn main() {
    let greeting = "Hello, Xen!";
    println(greeting);
    }
    • explc: enable explicit references with #![explc] immediately before a function, or #scope[explc] for a block. A callee’s annotation does not enable references in its caller.
    • opt: mark blocks with #scope[opt]. The default --opt=basic option applies to those blocks in build, run, and test; unmarked code is unaffected.
    • bb: a low-level facility for raw memory and operating-system calls. This release’s user documentation does not specify a detailed contract, so this guide offers an overview only. Start ordinary programs with the standard library.

    Consult the scope modes reference for the documented behavior.

    This guide assumes you have used variables, functions, and loops in another language. You do not need previous Xen experience.

    1. Installing Xen and your first program.
    2. Variables and values and data types and conversions.
    3. Functions and control flow, strings and collections, and structs and enums.
    1. Generics and type inference: known shapes, inference failures, and limits on generic operations.
    2. Copies, moves, and references: independent copies, ownership transfer, and borrowing.
    3. Scope modes: annotate callers and blocks with explc, then run marked opt code with CLI options.
    4. Slices and iterators: temporary views, lazy transformations, and consuming move-only items.
    5. Box and recursive data: finite recursive layouts, termination, and ownership through a list.
    1. Missing values and errors and working with multiple files.
    2. Build a word counter and test your code.

    Use the reference to look up language rules and APIs, or the examples for complete programs and expected output.

    These docs describe v0.1.0-demo.2. Syntax and APIs may change. Linux x86-64 is supported; AArch64 is experimental. Read the support scope.