Language overview
This topic is not available in the selected language or version. Showing the start of this section.
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.
Values and ownership
Section titled “Values and ownership”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);}Scope annotations
Section titled “Scope annotations”- 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=basicoption applies to those blocks inbuild,run, andtest; 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.
Guide contents
Section titled “Guide contents”This guide assumes you have used variables, functions, and loops in another language. You do not need previous Xen experience.
Core language
Section titled “Core language”- Installing Xen and your first program.
- Variables and values and data types and conversions.
- Functions and control flow, strings and collections, and structs and enums.
Ownership and advanced topics
Section titled “Ownership and advanced topics”- Generics and type inference: known shapes, inference failures, and limits on generic operations.
- Copies, moves, and references: independent copies, ownership transfer, and borrowing.
- Scope modes: annotate callers and blocks with
explc, then run markedoptcode with CLI options. - Slices and iterators: temporary views, lazy transformations, and consuming move-only items.
- Box and recursive data: finite recursive layouts, termination, and ownership through a list.
Build complete programs
Section titled “Build complete programs”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.