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

RFD-0014 — std ships with the toolchain; explicit imports — no auto-prelude

Committed Opened 2026-05-03 · Committed 2026-05-03

Question

Argon has a standard library covering math primitives, collections, meta-reflection, Kripke patterns, and test infrastructure. How does it ship — through the registry as packages, or bundled with the toolchain? And does the language auto-import any of it implicitly?

Decision

std ships with the toolchain. The standard library is part of the toolchain tarball alongside oxc, ox, ox-lsp. Substrate types (primitives — Nat, Int, Real, Bool, String, Decimal, Money, Date, DateTime, Duration) are Rust-side; library content (std::collection, std::meta, std::kripke, std::test) lives as .ar source under share/std/ resolvable by the toolchain.

Cargo-style layout for std internals. std mirrors the conventions of Cargo’s std layout: substrate types declared once in the compiler core; library content path-resolvable through the toolchain’s std bundle.

No implicit prelude. Modelers must use std::math::Nat; per module to reference primitives. Bare primitive names (Nat, Int) without an import produce OE0101 with a contextual hint that points at the appropriate std::* import.

[package] no_std = true opts out of std entirely. A no_std package gets no implicit primitives; everything resolves against the package’s own declarations and explicit imports.

use foo::bar::Sym; parses as a single-symbol Named import — Rust-style. The trailing Sym is the symbol being imported, not a module path being walked into.

Rationale

Toolchain-bundled std beats registry-distributed std. Registry-distributed std would have made std versioning and toolchain versioning independent, producing combinations that aren’t tested. Bundling them means every toolchain release ships with one specific std, and the combination is the unit of release.

Explicit imports beat auto-prelude. Auto-prelude saves five characters per module and costs an unbounded amount of “wait, where did this name come from” debugging when names collide or get shadowed. Explicit imports make every reference traceable to its source via grep.

Diagnostic hint over silent error. A bare Nat reference firing OE0101 with “did you mean use std::math::Nat;?” surfaces the fix immediately. Without the hint, modelers would have had to discover the import requirement by reading documentation.

Cargo-style layout. Argon’s package model already echoes Cargo (RFD-0012, RFD-0013). Aligning std layout with that convention means modelers who know Cargo know roughly how std works without re-learning.

Consequences

  • argon/oxc/src/std_meta.rs, std_math.rs, etc. carry the substrate-type registrations.
  • Toolchain tarball includes a share/std/ directory with the library-side .ar source.
  • ox-toolchain.toml resolution points the toolchain’s std bundle at the active toolchain.
  • Diagnostic OE0101 (bare-keyword fallthrough) generates four hint variants: known primitive, known collection, no_std-package context, none.
  • Existing .ar files migrated to explicit imports: argon-packages/ and argon/examples/lease-story/ carry use std::math::Nat; etc. on every module that references primitives.