@std/prelude

Overview

implicit scope
Symbols in @std/prelude are available in every Rasmalai source file out-of-the-box without an explicit import. Explicit imports are supported for disambiguation.

Names every compilation unit sees without an import.

An explicit declaration or an import always shadows a prelude name. The class stubs below are catalog-only: the frontend parses them once per session as a fallback scope and emits no code for them. Three items are real, though. Result is a generic enum merged into every program as std.prelude.Result, Promise and ArrayIter carry their bodies here, and the Array and String extensions below are compiled into every program too. Map and Set are stubs; their bodies live in @std/collections.

Ambient functions need no import either: print, assert, typeOf, IO, Thread, ThreadPool, Pointer, and Address.

An absent value is null, of type Null. Searches and lookups return null when nothing matches, and ?? substitutes a fallback. Query methods such as isOk lower to a discriminant check on the variant tag, and emit nothing until they are called.

.rnx
let xs: Array<Int> = [];
print(xs.find((x: Int): Bool => x > 0) ?? -1);

When to use it

The prelude is already imported everywhere: every file sees Option, Result, Array, Map, print, assert, and the Array/String extension methods with no import. Reference @std/prelude explicitly only to disambiguate a shadowed name.

Capabilities

  • Int/Float/Bool/String/Array/Map/Set
  • print/assert/typeOf intrinsics
  • Option/Result/Iterator
  • Array/String extensions

Symbols

  • class Any — Untyped escape hatch. Nothing on an Any is resolved statically, so
  • class Array — Dense growable sequence with Int indexes.
  • class ArrayIter — Index-based iterator over an array. It holds the array and a cursor,
  • class Bool — Foundation boolean type: true or false.
  • class Char — Single scalar view into a String. The checker treats a Char as a
  • class Date — Calendar view over the wall clock. Catalog stub: @std/time owns the
  • class Error — Error value. Catalog stub: throw raises a String message and
  • class FastFloat — Relaxed float type.
  • class Float — Foundation float type: an IEEE-754 double.
  • class GenRef — Generational reference for cyclic edges. GenRef.of(x) takes a
  • class Int — Foundation integer type: a signed 64-bit whole number.
  • class Map — Insertion-ordered key-value table. Catalog stub: Map and its
  • class Promise — One-shot eventual value: Pending (0), Fulfilled (1), Rejected (2).
  • class PromiseResult — Settlement record for Promise.allSettled. One per input promise,
  • class PromiseWithResolvers — Manual settlement handles from Promise.withResolvers. It holds the
  • class RnxHost — Host metadata: rnx is ambient in every module with no import.
  • class Set — Distinct-member collection. Catalog stub: Set and its methods live
  • class String — Canonical UTF-8 string type.
  • class Void — Absence of a return value. Void marks a function that only has
  • enum Result