Nori language

21. Keyword Reference

Every Nori keyword, with a one-line meaning and where it is defined. Nori has a small set of reserved words (never usable as identifiers) and a larger set of contextual words (keywords only in a specific position, ordinary identifiers elsewhere; see Lexical Structure.

Reserved words

WordMeaningChapter
asimport alias: import "…" as name13
breakexit the innermost (or labeled) loop7
continuenext iteration of a loop7
deferrun a statement when the enclosing block ends, by any path7
elsealternative branch; also the fallback operator7, 14
enumdeclare a sum type11
falsethe Bool false3
fndeclare a function8
foreachiterate a range or collection7
ifconditional (statement or expression)7
implmethod / trait implementation block10, 12
importbring in a module13
inthe foreach x in … separator7
inoutname a value you may change: write-back for a scalar, permission to mutate for a handle; at a store position, share it with the container8, 15
lawa universally-quantified property19
letimmutable binding4
lockenter a mutex's critical section16
matchpattern match11
overthe reduction domain in reduce … over …16
reduceparallel reduction16
regionscoped allocation arena15
returnreturn from a function8
scheduleattach a scheduling strategy to a loop nest16
setwrite-through ownership hint15
sinkmove the value: sink x, sink r.f, sink g on a global (the place is left empty), match sink x, sink parameter15
spawnstart a concurrent task16
structdeclare a product type10
traitdeclare an interface12
truethe Bool true3
unsaferaw-memory / FFI block17
viewa read-only second name that owns nothing and is deep: nothing reachable through it may change; also -> view T results and f: view T fields15
copya deep copy with its own owner; changing it never affects the original15
varmutable binding4
whileconditional loop7

Contextual words

These are keywords only in the position shown; anywhere else they are ordinary identifiers.

WordMeaningChapter
pubexport an item from its module13
fornames the type an impl is for: impl Trait for Type; a name everywhere else, so let for = 1 is legal12
globala top-level constant4
threadlocalthreadlocal global: one copy of the global per thread (per CPU in a freestanding image)4, 16
frozenfrozen global: written only before the first spawn, so a task may read it16
nakednaked fn: no prologue or epilogue, for freestanding entry points17
recorddeclare a raw memory layout as a type: values are addresses, fields are loads and stores17
@section / @align / @code32on a naked fn: the section its assembly block is placed in, its alignment, and 32-bit mode17
@irqon a function: an interrupt handler, which with everything it calls may neither allocate nor block (on an extern fn or a naked fn: its author's word that it does not)17
@takes(L) / @needs(L) / @sleeps / @nospinon a function: lock effects: what locks it (or its caller) holds, and whether it may block (@sleeps) or provably never does (@nospin); checked over the whole call graph against a lockorder declaration17
cstructa raw-memory record with C layout: fixed-width fields, cnew/cfree, s.field access, views, sizeof/offsetof17
packedpacked cstruct: the same, with every field at offset 0,1,2,… (alignment 1, no padding): the x86 tables C alignment cannot say17
noriextern nori fn: a Nori-ABI symbol defined in a separately-compiled dependency17
durablea global that persists across program runs (durable var)4
migrateload an older persisted shape through a converter (durable var X: T migrate from Old with fn; a plain global may carry clauses too, for snapshot() images)4
transienta struct field that is derived state: never persisted, rebuilt empty on load, and outside the schema4
externdeclare a C-ABI function / inline C17
fromextern fn f(..) -> R from "libz.so.1": the shared library a C function is imported from; also migrate from17, 4
cfgconditional compilation18
namespacegroup declarations under a sub-name13
usebring a name into scope from a namespace13
versioneda value with undo/redo history19
protocola two-party conversation as a type; <role> sends <Type> steps16
sendsone step of a protocol16
streamsa protocol step that repeats zero or more times16
choosesa protocol step where one role picks a branch16
awaitwait for a Task to finish16
parallelfork/join block or parallel loop16
withindeadline-bounded execution16
racerun branches, take the first16
hedgestart a backup only if the primary is slow16
selectwait on channels and/or a timeout16
untilasync placeholder that upgrades in place16
yieldpublish a best-so-far in a within block16
nevera whole-program policy that must not be violated19
shadow / shadowsdifferential replacement of a function19
deprecatedwarn at every call site of a name you still export13
withan oracle for a shadowed function19
orthe second branch of race/hedge16

Not keywords

Core operations (printl, push, pop, len, slen, to_str, vec, map, fill, channel, mutex, spawn's partner built-ins, and the rest) are built-in functions, not keywords. They live in the ordinary function namespace and are documented with the types they operate on.


Next: Grammar Summary.


← The manifest · Contents · 22. Grammar Summary →