The Nori Language
The language reference: every construct of the Nori language, its syntax, and its semantics. It describes what the compiler (noric) accepts and how programs behave. For the standard library, see the standard library reference.
The code examples are meant to compile with the accompanying noric. Examples are shown as complete programs or as fragments inside fn main, and expected output is given in comments.
Contents
- Getting Started: a first program, how source files are compiled (
noric), androllprojects. - Lexical Structure: comments, identifiers, the reserved and contextual keywords, tokens, and source encoding.
- Values and Types: the type system:
Int,Float,Bool,Char,Str, sized integers, vector types (explicit SIMD), containers, and the built-in generic types; the all-i64value model. - Variables and Bindings:
let,var,global, type annotations, scope, and the no-block-shadowing rule. - Operators: arithmetic, bitwise, comparison, logical, and string operators, with precedence.
- Strings and Characters:
Str, the strictChartype, interpolation, escapes, and the text builtins. - Control Flow:
if/else(andifas an expression),while,foreach,match,break/continueand loop labels. - Functions and Closures:
fn, parameters,inout, return types, recursion, and|x| …closures. - Collections:
Vec<T>,Map<K, V>,Set<T>, fixed arrays (fill), andPool<T>. - Structs: declaration, fields, methods (
impl), and structs are handles;copytakes an independent value. - Enums and Pattern Matching: sum types, payloads,
match, and the built-inOption/Result/Json. - Traits and Generics:
trait/impl, bounds, dynamic dispatch (trait objects), and monomorphized generics. - Modules and Namespaces:
import,import … as,::,pubvisibility, directory modules, andnamespace. - Error Handling:
Result/Option,try,fail, and error traces. - The Memory Model: value semantics, no aliasing by construction, automatic reclamation, and
region. - Concurrency:
spawn/Task<T>/await,parallel, channels,lock, and deadline control flow (within/race/hedge/select/until,yield). - Unsafe and FFI:
unsafe, raw memory (peek/poke),extern fn,cstruct, inlineasm,naked fn, and C interop. - Conditional Compilation:
cfg(os/arch/libc)and user flags (--cfg). - Verification and Contracts:
law, performance contracts (noalloc/notrap/bounded),neverblocks,shadowfunctions,versionedvalues,why, and proof-carrying builds. - Tooling:
noricflags,roll,--test,--doc,--fmt, the LSP,--xray, and--memprof. Its companion, The Manifest: every key ofnori.manifest, the file at the root of every project. - Keyword Reference: every keyword, contextual or reserved, with a one-line meaning and a link.
- Grammar Summary: a consolidated syntactic overview.