Advanced topics
Most programs never need the chapters below. They cover niche corners of the language: grouping values without a declaration, overlapping storage, callbacks, and custom operators. Read the everyday chapters first, and come back here when you need one of these.
- Anonymous structs group a fixed set of named fields into a single value without declaring a named struct.
- Unions overlap members in storage, for type punning and matching C unions imported from headers.
- Function pointers store functions in values and pass callbacks, including C callbacks.
- Operator overloading defines operators for user-defined types.
- Type aliases give short names to long types.
- Private restricts declarations to their module.
- Namespaces scope a file's declarations under one name.
- Iterators define how collections work with
forloops. - Interfaces declare behavior shared across types.
- Generics parameterize functions and types over other types.
undefinedexplicitly marks a variable as uninitialized.- Context carries implicit settings like the allocator.
- Arena bump-allocates short-lived groups of values.
- Defer and destructors run statements and release resources at scope exit.
- Assertions check conditions that must hold.