Skip to content

Gossamer language reference

One page per language feature. Source is crates/gossamer-std/src/manifest/feature_status.rs; this index is regenerated from manifest::FEATURE_STATUS by gos doc --emit-stdlib.

Feature Summary
lang::let Immutable binding.
lang::let_mut Mutable bindings can be reassigned and can be the source of &mut.
lang::if Conditional expression.
lang::match Exhaustive pattern match expression.
lang::if_let Single-variant pattern sugar.
lang::while_let Loop that drains while a pattern matches.
lang::for Iterator-driven loop.
lang::loop Unconditional loop with break value.
lang::break Exit the innermost loop, optionally with a value.
lang::continue Skip to the next iteration of the innermost loop.
lang::return Exit the enclosing function with a value.
lang::question_mark Short-circuit Result / Option propagation operator.
lang::pipe Forward-pipe operator |>, for composing free functions in a functional style. A step is either a bare callable (x |> f) or a closure whose parameter is the piped value (x |> |v| f(a, v)). Methods chain on their own and are the shorter spelling; a method chain can feed a pipe.
lang::closure Lambda expression |args| body.
lang::callback_shorthand A callback written without |v|: a std free function named in value position stands for the closure that calls it, as in xs.map(math::abs).
lang::fn Function declaration.
lang::struct Product type declaration.
lang::enum Sum type declaration with payload-carrying variants.
lang::trait Behaviour interface declaration.
lang::impl Inherent and trait implementation blocks.
lang::generics Type parameters on functions / impls / structs.
lang::go Goroutine spawn, detached.
lang::cohort Structured concurrency: cohort { } owns the goroutines spawned inside it, joins them on every exit path, and reports the first failure as its Result.
lang::triple_quoted_string """ string literal whose body is dedented by the indentation it shares with its closing delimiter; gos fmt moves the block with the line that opens it.
lang::select Channel multiplex select expression.
lang::channel Typed channel via std::sync::channel.
lang::weak_references Weak<T> downgrade/upgrade handles. Native collection is thread-local only and the bytecode VM has no cycle collector, so cross-tier cyclic reclamation is not yet a Stable guarantee.
lang::spawn Goroutine join handle: spawn(f) -> JoinHandle<T>, .join() -> Result<T, String>.
lang::macros Built-in macros only - no user-defined macros: the format family (print/println/eprint/eprintln/format/panic), the desugar macros (matches!/todo!/unimplemented!/unreachable!/dbg!), and the build-time regex!/sql!/codegen!.
lang::doctest Fenced code in // doc comments runs under gos test.
lang::cfg Conditional compilation attribute.
lang::attribute Built-in attributes (#[cfg], #[test], #[bench], #[derive]).
lang::const Compile-time constant binding.
lang::static Module-level mutable or immutable static slot.
lang::opaque_nominal_alias type Name = new Repr declares a distinct nominal type over an unchanged runtime representation, erased before lowering so no tier sees one. It inherits equality, ordering, hashing, and formatting - which describe the value both sides share - and nothing else: arithmetic needs the alias's own impl Add, and the representation's methods are not in scope. .into() converts to and from its own representation; any other pair needs impl From.
lang::slicing A range in index position takes a subsequence: xs[1..3], xs[..k], xs[k..], xs[..], xs[a..=b], over fixed arrays, slices, Vec, and String. Bounds clamp rather than panic, matching substring; a String slice takes byte offsets and snaps to codepoint boundaries.
lang::visibility Three visibilities: private by default (the declaring module and its descendants), pub(package) (every module of the declaring package), and pub (the package's public API). Declared per item, per method, and per struct field; pub(crate) / pub(super) / pub(in path) are rejected (GP0038).
lang::type_alias Transparent type alias: type X = T (and generic type Pair<A> = (A, A)) is interchangeable with its target everywhere; a cyclic alias is rejected (GT0024).
lang::mut_ref_params Local &mut aliases write through; &mut Vec<T> / &mut [T] parameters write through on every tier.
lang::unicode_identifiers Identifiers follow UAX #31 (matches Rust 2024).
lang::comptime Zig-style compile-time evaluation: comptime { ... } blocks, comptime fn calls, and comptime parameters run on the bytecode VM during compilation and fold to a literal, so every tier compiles the identical constant. typeInfo::<T>() reflects a struct's fields, a tuple struct's positions, or an enum's variants - substituting the arguments for a generic instantiation - and a for (name, ty) in typeInfo::<T>() loop unrolls into native per-field code, and codegen!(...) splices a comptime fn's String back as source. Includes the regex! / sql! build-time validation macros.
lang::keyword_arguments Keyword arguments and constant parameter defaults: a call may name any parameter (volume(depth = 4, width = 2)), and a parameter may declare a constant default (fn volume(width: i64, height: i64 = 2)) that is spliced into every call omitting it. Positional arguments come first, then names. Both are caller-side spellings rewritten into the callee's declared order before type checking, so the calling convention is unchanged. A name on a method call is matched when every type declaring that method name would rewrite the call identically; when they disagree the call is reported (GR0013) rather than guessed.
lang::move_keyword move closure capture keyword - declined permanently (SPEC 17.5). Capture is automatic and the runtime manages ownership, so move would annotate a decision the language does not make.
lang::async_await async fn / .await - declined permanently (SPEC 17.5). Goroutines and channels cover the same shape without colored functions.
lang::lifetimes Explicit lifetime annotations and a borrow checker - declined permanently (SPEC 17.5). References have implicit lexical lifetimes ending at the closing brace, and the lexical &mut check is the intended ceiling.