Skip to content

Standard Library API Shape

This document defines the recommended API design shape for Beskid’s standard library. Detailed module contracts live in docs/standard-library/.

  1. Predictable naming and discoverability.
  2. Minimal surface area for MVP.
  3. Composable modules over monolithic APIs.
  4. Stable contracts that can be backed by interop dispatch internally.

Recommended top-level modules:

  • Core (error handling, results, string primitives)
  • Collections (array/list/map/set/queue/stack)
  • Query (query contracts, operators, execution)
  • System (IO, FS, Path, Time, Environment, Process)

For MVP, start with:

  • Core.String
  • Collections.Array
  • Query
  • System.IO
  • Public APIs must not require a Std namespace prefix.
  • Standard library modules are addressed directly by canonical module paths (Core.String, Collections.Array, Query, System.IO, …).
  • Existing Std.* spelling is considered legacy documentation form and should not appear in new docs/examples.
  • System.IO.Print
  • System.IO.Println
  • Core.String.Contains
  • StringBuilder
  • Duration
  • PathInfo
  • Avoid hidden allocations in APIs that look cheap.
  • Avoid broad Any-style parameters.
  • Prefer total APIs where failure is impossible or exceptional.
  • Use Result-based forms for expected recoverable failures.
  • Canonical language-level Result semantics live in docs/spec/error-handling.md.
  • Canonical stdlib Result API contracts live in docs/standard-library/Core/Results.md.
  • Public stdlib APIs remain stable while runtime internals evolve.
  • Runtime ABI/syscall ownership and backend parity are defined in docs/execution/runtime/syscalls-and-abi-boundary.md.
  • Language-level Extern syntax and typing are defined in docs/spec/ffi-and-extern.md.
  • std API changes should be additive in minor releases.
  • Breaking rename/removal requires a migration note.
  • New experimental modules should be prefixed or documented as unstable.

Per-module API contracts are canonical in docs/standard-library/:

  • Core/
  • Collections/
  • Query/
  • System/
  • Query protocol and operator contracts: docs/standard-library/Query/.
  • Lambda/closure language semantics: docs/spec/lambdas-and-closures.md.
  • for in language semantics: docs/spec/control-flow.md.