Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix A: Keywords

The following words are reserved by the Kāra language. You cannot use them as identifiers.

Declaration keywords

KeywordPurpose
fnDeclare a function
structDeclare a struct
enumDeclare an enum
traitDeclare a trait
implImplement a trait or add methods to a type
typeDeclare a type alias
distinctDeclare a distinct (newtype) alias
constDeclare a compile-time constant
modDeclare a module
useBring a name into scope
importImport an external package
externDeclare a foreign function or type
sharedMark a struct or enum as reference-semantics (RC)
layoutDeclare a physical memory layout for a struct
groupGroup fields within a layout block
effectDeclare an effect system definition
resourceDeclare an effect resource
verbDeclare an effect verb
aliasDeclare that two resource names refer to the same underlying resource

Visibility keywords

KeywordPurpose
pubPublic — visible to external consumers
privatePrivate — visible only within the current directory

(Default visibility — no keyword — is project-internal: visible to all files in the project.)

Control flow keywords

KeywordPurpose
ifConditional branch
elseFallthrough branch for if
matchPattern-matching switch
whileCondition-driven loop
forIterator-driven loop
inSeparator between pattern and iterable in for
loopInfinite loop
returnEarly return from a function
breakExit from a loop
continueSkip to the next loop iteration
deferRun a block when the enclosing scope exits (success path)
errdeferRun a block when the enclosing scope exits via ?-propagated error
asmInline assembly block
global_asmModule-level assembly block

Binding keywords

KeywordPurpose
letDeclare a local binding
mutMark a binding or parameter as mutable

Ownership and borrowing keywords

KeywordPurpose
ownExplicit owned parameter mode (rarely needed — owned is the default)
refBorrow a value (read-only reference)
weakWeak reference into an RC type
lockLock resource

Effect keywords

KeywordPurpose
readsEffect: reads from a resource
writesEffect: writes to a resource
sendsEffect: sends to a resource
receivesEffect: receives from a resource
allocatesEffect: allocates from a resource
panicsEffect: may panic
blocksEffect: may block the calling thread
suspendsEffect: may yield to the scheduler
withIntroduce an effect annotation or effect variable
transparentMark an effect as transparent (not attributed to callers)
stableMark an effect annotation as part of the public API contract
seqSequential block
parParallel block (branches may execute concurrently)
yieldYield a value from a generator

Type system keywords

KeywordPurpose
asType cast or trait disambiguation
whereIntroduce generic bounds or refinement-type predicates
dynDynamic dispatch through a trait object
SelfThe type of the current impl block or trait
selfThe receiver value within a method

Contract keywords

KeywordPurpose
requiresPrecondition contract on a function
ensuresPostcondition contract on a function
invariantInvariant check at the end of every method in an impl block

Safety keywords

KeywordPurpose
unsafeMark a block or function as bypassing safety checks

Concurrency and context keywords

KeywordPurpose
providersIntroduce a provider scope
independentDeclare that two resources are independent for conflict analysis

Literal keywords

KeywordPurpose
trueBoolean true
falseBoolean false

Reserved for future use

These words are reserved now; using them as identifiers is a compile error.

KeywordPlanned use
f16Half-precision float (Phase 7+)
bf16Brain-float (Phase 7+)

Primitive type names

These are lexer-level keywords, not identifiers. They are always in scope and require no import.

i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, bool, char, ! (the never type)