sysl

Language Reference

The language in full, organized for looking things up rather than for reading through.

The tour teaches sysl in the order the ideas are easiest to learn. This section covers the same language for lookup: every construct is described once, in its own place, with its rules complete.

It answers specific questions. What may follow for? Which conversions are implicit? What does ? do to a &T payload? When is a closure boxed?

Every example is checked. Every program on these pages is compiled and run by the test suite, and every refusal shown is quoted from the compiler’s own diagnostic, so a page that disagrees with the compiler fails the build. Where a rule has an edge case, the edge case is shown as a program.

Rules are given with their reasons where the reason helps you predict behaviour. sysl’s rules depend on one another — the memory model determines what a closure costs, which determines what a trait object can be, which determines what a generic can promise — so those connections are stated where they matter.

How this section is organized

The pages run from the smallest units upward: what the compiler reads, then types, then expressions, then the declarations that bind them, and then the systems built on top — memory, traits, generics, reflection, modules, errors, async and tasks, the foreign interface, and the forms that run during compilation.

Compact reference is the whole language on a single page: tables, one-line rules and the common idioms, for a reader who already programs and wants the rules without the explanation, or for a tool reading them on a budget. Everything on it is stated in full elsewhere in this section.

Packages describes sysl.hocon and dependencies on other people’s code. It is a build-time concern rather than a rule about expressions, but it determines which modules a program has.

The standard library is documented separately. It is ordinary sysl — no type in it is a language feature, and a program could have written any of it.

This section is the specification. It describes what the language is, and gives the reason for a rule wherever the rule would otherwise be hard to predict.

Pages

  • Lexical structure — What the compiler reads before it parses anything — tokens, literals, and the layout rules that decide where a statement ends.
  • Types — Every type the language has — the open integer families, the closed float set, and the aggregates built on them.
  • Expressions and operators — The precedence ladder, every operator's meaning, evaluation order, and the traits an operator dispatches through.
  • Statements and control flow — Blocks, bindings, every loop and branch form, and what each one yields — because in sysl most of them yield something.
  • Declarations — Bindings, functions, structs, enums and type declarations — what each form states, and what it leaves to be inferred.
  • Patterns and matching — Every pattern form, how arms are chosen, what guards do to exhaustiveness, and what alternatives may bind.
  • Memory — The kinds of name, the block lifetimes the compiler checks without being told, the annotations, destructors, crossing a domain, places and `ref`, and the raw tier.
  • Arrays and slices — Two sequence types — storage and a view of it — and the rules for writing one down, indexing it, slicing it, and knowing what it keeps alive.
  • Fixed-point numbers — `q31`, `i32q16`, `u32q32` — an integer counted in units of 2^-F, with the arithmetic a DSP wants: saturating, rounding to nearest, mixed formats read from where a result goes, and literals that are constant data on a board with no FPU.
  • Vectors — `T` is an array that computes lane-wise — one instruction for N additions, one kernel for every register width, and it still compiles where there is no vector unit at all.
  • Strings — An immutable, validated `[]u8` — the representation, the guarantee, every form that makes new bytes, and where the allocator line falls.
  • Traits — The one polymorphism mechanism — declaring, implementing, coherence, associated types, required traits, and trait objects.
  • Generics — Type parameters, bidirectional inference, bounds checked at the definition, and monomorphization.
  • Reflection — What a type answers about its own make-up while compiling — kind, name, fields, variants, annotations — and how a library writes a derivation from it.
  • Modules — A module is a directory — visibility, imports, the acyclic graph, where a program starts, and separate compilation.
  • Packages — sysl.hocon, dependencies on other people's code, version selection, and what a fetched package's modules are called here.
  • sysl config — The commands that edit sysl.hocon without disturbing it, and the one that shows what a project's manifests resolve to.
  • Errors, traps and contracts — Two channels for failure — a value you handle and a stop you cannot — plus the constrained types, invariants and contracts that decide which one you get.
  • Async and tasks — Async functions, the Task they hand back, await, the executor contract, frames on the heap, cancellation by drop, and when a task may cross a concurrency domain.
  • The foreign interface — `extern`, link names, intrinsics, function addresses, variadics, opaque handles, interrupt handlers, and a library that carries C.
  • Inline assembly — Machine instructions, in an arm per architecture — where operands are values and the compiler owns the constraint string, the escaping, and the labels.
  • Attributes, annotations, and compile time — `::` attributes a type answers, the nineteen annotations a function takes, the three that lay out or place what they mark, the six a file's header takes, `@assert` which stands on its own, and the `#if` directive that gates lines before the lexer sees them.
  • Verification — Quantifiers, loop invariants, termination measures, `@pure`, `@reads`/`@writes`, `@ghost`, and `sysl prove` — the clauses that say what a program means, and the prover that reads them.
  • Compact reference — The whole language on one page, for a reader who already programs — tables and one-line rules instead of explanation, with the idioms that keep new code in style.

Search

Esc
↑↓ to navigate ↵ to open Esc to close