Ultraviolet Developer Handbook
Docs / Handbook
The Ultraviolet Developer Handbook is the public reference for learning and writing Ultraviolet. It is generated from the handbook chapter parts maintained in the language repository and published here as stable website pages.
Generated handbook.
Source snapshot:
handbook
SHA-256: a5d21aff583bfbb6d9db8ef52b842fec80adad1864f5846488ab5bc00e090e24
Reference Tree
Section titled “Reference Tree”-
2. Conformance, Behavior Types & the Phase Model
-
3. Projects, Manifest, Modules & the Compilation Model
- 3.1 Core Project Records
- 3.2 The Ultraviolet.toml Manifest
- 3.3 Assemblies and Project Loading
- 3.4 Deterministic Ordering and Case Folding
- 3.5 Source Roots, Module Directories, and Compilation Units
- 3.6 Output Artifacts and Linking
- 3.7 Tool Resolution and IR Assembly Inputs
- 3.8 Project Diagnostics
- The uv Command Line
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
4. Source Text & Lexical Structure
- 4.1 Source Loading and Normalization
- 4.2 Lexical Analysis
- 4.2.1 Character Classes
- 4.2.2 Keywords and Reserved Lexemes
- 4.2.3 Identifiers
- 4.2.4 Integer Literals
- 4.2.5 Floating-Point Literals
- 4.2.6 Boolean and Null Literals
- 4.2.7 Character Literals
- 4.2.8 String Literals
- 4.2.9 Escape Sequences
- 4.2.10 Operators and Punctuators
- 4.2.11 Comments and Doc Comments
- 4.2.12 Maximal Munch and Token Selection
- 4.2.13 Newlines and Statement Termination
- 4.2.14 Lexical Security: Bidi, Confusables, and Mixed Scripts
- 4.3 Source Loading and Lexical Diagnostics
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
5. Names, Scopes & Visibility
- 5.1 The Scope Context and Identifier Kinds (§7.1)
- 5.2 Name Introduction and Module Validation (§7.2)
- 5.3 Lookup and Qualified Resolution (§7.3)
- 5.4 Visibility and Accessibility (§7.4)
- 5.5 Top-Level Name Collection (§7.5)
- 5.6 Qualified Disambiguation (§7.6)
- 5.7 Shared Resolution Helpers and the Resolution Pass (§7.7)
- 5.8 Referencing Names Across Modules and Assemblies
- 5.9 Idioms & Best Practices
- 5.10 Pitfalls & Diagnostics
-
7. The Type System Core: Equivalence, Subtyping & Inference
- 7.1 Type Equivalence (≡)
- 7.2 Subtyping (<:)
- 7.2.1 Where subtyping does *not* widen: numerics and permissions
- 7.2.2 The bottom type
- 7.2.3 Structural (covariant) subtyping
- 7.2.4 Pointer and modal subtyping
- 7.2.5 Functions, closures, and async: contravariant parameters
- 7.2.6 Union subtyping: membership and width
- 7.2.7 Generic subtyping and declared variance
- 7.2.8 Reflexivity and transitivity
- 7.3 Type Inference
- 7.3.1 Type variables and substitutions
- 7.3.2 The unifier
- 7.3.3 The solver
- 7.3.4 Bidirectional synthesis and checking
- 7.3.5 Inference for literals
- 7.3.6 Subsumption, pointer-null, and modal subsumption at use sites
- 7.3.7 Where types may be omitted, and where they are required
- 7.3.8 Inference for generics
- 7.3.9 Inference for tuples, arrays, and unions
- 7.4 Metatheoretic Properties
- 7.5 Core Type Diagnostics
- 7.6 Idioms & Best Practices
- 7.7 Pitfalls & Diagnostics
-
9. Modal Types & Typestate
- 9.1 Modal Declarations (§13.1)
- 9.2 State Fields (§13.2)
- 9.3 State-Specific Methods (§13.3)
- 9.4 Transitions (§13.4)
- 9.5 Modal Widening (§13.5)
- 9.6 Matching and Dispatch on Modal State (§13.1.5, §16.7, Chapter 17)
- 9.7 A Complete Worked Lifecycle
- 9.8 Modal vs. Booleans and Enums — When to Use Which
- 9.9 Idioms & Best Practices
- 9.10 Pitfalls & Diagnostics
-
10. Strings, Bytes & Text Handling
- 10.1 The Two Type Families at a Glance
- 10.2 String Types (§13.6)
- 10.2.1 The Operation Surface
- 10.2.2 String Literals and the string@View Type
- 10.2.3 Length and Emptiness
- 10.2.4 Constructing an Owned string@Managed
- 10.2.5 Borrowing a View From an Owned String
- 10.2.6 Slicing With UTF-8 Boundary Safety
- 10.2.7 Appending to an Owned String
- 10.2.8 Conversions and Encoding Guarantees
- 10.2.9 Worked Example: Read-Only Inspection
- 10.3 Bytes Types (§13.7)
- 10.4 Bridging String and Bytes
- 10.5 Idioms & Best Practices
- 10.6 Pitfalls & Diagnostics
-
16. Contracts: Preconditions, Postconditions, Invariants & Verification
- 16.1 The Contract Clause (§15.4)
- 16.2 Preconditions (§15.5)
- 16.3 Postconditions: @result and @entry (§15.6)
- 16.4 Invariants (§15.7)
- 16.5 Verification Logic: what is proved vs checked (§15.8)
- 16.6 Behavioral Subtyping (§15.9)
- 16.7 Idioms & Best Practices
- 16.8 Foreign Contracts on extern Procedures (§23.6)
- 16.9 Pitfalls & Diagnostics
-
17. Expressions & Operators
- 17.1 Operator Precedence and Associativity (Overview)
- 17.2 Literal and Name Expressions (§16.1)
- 17.3 Access and Place Expressions (§16.2)
- 17.4 Call Expressions (§16.3)
- 17.5 Operator Expressions (§16.4)
- 17.6 Cast and Transmute Expressions (§16.5)
- 17.7 Construction Expressions (§16.6)
- 17.8 Control Expressions (§16.7)
- 17.9 Effectful Core Expressions (§16.8)
- 17.10 Closure and Pipeline Expressions (§16.9)
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
19. Statements, Blocks, Regions, Frames & Defer
- 19.1 Blocks and Block Values (§18.1)
- 19.2 Binding Statements: let and var (§18.2)
- 19.3 Local using Statements (§18.3)
- 19.4 Assignment Statements (§18.4)
- 19.5 Expression Statements (§18.5)
- 19.6 defer (§18.6)
- 19.7 region — Arena Scopes (§18.7)
- 19.8 frame — Stack-Like Scopes (§18.8)
- 19.9 Control-Transfer Statements: return, break, continue (§18.9)
- 19.10 unsafe Statements (§18.10)
- 19.11 Idioms & Best Practices
- 19.12 Pitfalls & Diagnostics
-
21. Authority, Capabilities, Regions & the Memory Model
- 21.1 The Authority Model (§6.1)
- 21.2 Host Primitives (§6.2)
- 21.3 Binding and Permission Runtime State (§6.3)
- 21.4 Regions, Frames, and Provenance (§6.4)
- 21.5 Dynamic Scope Stack, Bindings, and Region Runtime (§6.5)
- 21.6 Runtime State and Memory Diagnostics (§6.6)
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
22. Attributes, Metadata & Source-Native Tests
-
23. The Key System: Shared-Memory Concurrency
- 23.1 Why Keys Replace Runtime Mutexes
- 23.2 Key Paths (§19.1)
- 23.3 Key Acquisition Blocks (§19.2)
- 23.3.1 Key-Block Syntax
- 23.3.2 Key Triples, Modes, and Mode Ordering
- 23.3.3 Coverage and Implicit Acquisition
- 23.3.4 Explicit Block Acquisition and Canonical Order
- 23.3.5 Scope-Bound Release and Escape Rules
- 23.3.6 Closure Capture of shared Bindings
- 23.3.7 Worked Example — A %write Block over Two Paths
- 23.4 Conflict Detection (§19.3)
- 23.5 Nested Release (§19.4)
- 23.6 Speculative Execution (§19.5)
- 23.7 Dynamic Key Verification (§19.6)
- 23.8 Memory Ordering (§19.7)
- 23.9 Key Propagation and the Static Replacement of Mutexes
- 23.10 Capstone Worked Example — A Guarded Shared Counter
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
24. Structured Parallelism
- 24.1 Parallel Blocks (§20.1)
- 24.2 Execution Domains (§20.2)
- 24.3 Capture Semantics (§20.3)
- 24.4 Spawn, Spawned<T>, and Wait (§20.4, §21.2)
- 24.5 Dispatch — Parallel Loops (§20.5)
- 24.6 Cancellation (§20.6)
- 24.7 Panic Handling Across Tasks (§20.7)
- 24.8 Determinism and Nesting (§20.8)
- 24.9 Worked Structured-Concurrency Example
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
25. Asynchronous Operations
- 25.1 The Async Type
- 25.2 Suspension Forms
- 25.3 Composition Forms
- 25.3.1 Async iteration — loop pat in async
- 25.3.2 Manual stepping
- 25.3.3 sync — driving an async to completion synchronously
- 25.3.4 race — first-to-settle wins
- 25.3.5 all — join all results
- 25.3.6 The async combinators
- 25.3.7 until — a source-specified surface on shared values
- 25.3.8 Composition diagnostics
- 25.4 The Async State Machine Model
- 25.5 Async–Key Integration
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
27. Foreign Function Interface (FFI)
- 27.1 FfiSafe — Which Types May Cross the Boundary
- 27.2 Extern Procedures — Calling Foreign Code
- 27.3 Foreign-Callable Procedure Exports — Exposing Ultraviolet to Foreign Callers
- 27.4 FFI Attributes
- 27.5 Capability Isolation Across the FFI Boundary
- 27.6 Foreign Contracts
- 27.7 The extern Block Shell (§11.4)
- 27.8 Boundary Unwinding and Panic Safety
- Idioms & Best Practices
- Pitfalls & Diagnostics
-
28. Program Lifecycle, Drop, ABI & Runtime
-
29. Complete Grammar Reference
- 29.1 B.1 — Lexical Grammar
- 29.2 B.2 — Type Grammar
- 29.3 B.3 — Expression Grammar
- 29.4 B.4 — Pattern Grammar
- 29.5 B.5 — Statement Grammar
- 29.6 B.6 — Declaration Grammar
- 29.7 B.7 — Contract Grammar
- 29.8 B.8 — Attribute Grammar
- 29.9 B.9 — Key System Grammar
- 29.10 B.10 — Concurrency Grammar
- 29.11 B.11 — Async Grammar
- 29.12 B.12 — Metaprogramming Grammar
- 29.13 B.13 — FFI Grammar
- 29.14 B.14 — Region Grammar
- 29.15 Appendix C — AST Form Index (Quick Map)
- 29.16 Cross-Section Token Cautions
- 29.17 Idioms & Best Practices
- 29.18 Pitfalls & Diagnostics
-
30. Style, Naming & Engineering Best Practices
- 30.1 Naming
- 30.2 Formatting
- 30.3 Module, Directory, and File Organization
- 30.4 Imports and Visibility
- 30.5 Type Design
- 30.6 Contracts, Invariants, and Safety Semantics
- 30.7 unsafe, #dynamic, and FFI
- 30.8 Procedures and API Design
- 30.9 Module-Scope State
- 30.10 Comments and Documentation
- 30.11 Review Expectations
- Idioms & Best Practices
- Pitfalls & Diagnostics