Skip to content

Standard library

The xtc standard library is a set of .xt classes that ship alongside the compiler. Each class is #import-able by name; methods are predominantly static, so most calls look like Stdio.print("hi\n") or Math.rand() with no instance needed.

support/
generic/lib/ ← platform-agnostic classes (work on every target)
Foundation.xt ← umbrella: Number + String + Data + Array + Comparable
Object.xt ← the runtime's root class
Number.xt String.xt Data.xt Array.xt Map.xt Set.xt Memory.xt
Comparable.xt Hashable.xt Enumerable.xt ← protocols
Assert.xt Sort.xt
atari/lib/ ← Atari-specific classes
Stdio.xt Math.xt Time.xt Heap.xt System.xt Vbi.xt FILE.xt
Gfx.xt Gfx6.xt Gfx7.xt Gfx8.xt Gfx15.xt GfxFactory.xt ← graphics (not yet documented)
mapData.xt symbols.xt ← (not yet documented)
commodore/lib/ ← C64 mirrors: Stdio / Math / Time / System
arm64/lib/ ← host (arm64) target: Stdio / Math / Time / Heap / FILE
6502/asm/ ← 6502 assembly runtime (mul/div, heap, float) — not .xt classes

The compiler’s #import machinery searches platform-specific paths first, then falls through to generic/lib/, so a class with the same name in both wins on the active platform. That’s how Stdio.xt gets per-platform implementations while the Foundation framework (Object, Number, Array, …) and helpers like Assert / Sort stay shared.

Most library methods are static. You can call them three ways:

#import <Stdio.xt>
void main(void) {
Stdio.print("explicit\n"); // class.method()
}
#import <Stdio.xt>
use Stdio; // language-level promotion
void main(void) {
print("bare-call\n"); // resolves to Stdio.print
}
#use Stdio // preprocessor sugar:
// #import + use in one line
void main(void) {
print("shortest form\n");
}

Bare-call promotion (use Stdio; and the #use shorthand) is documented under Classes → Bare-call promotion and Preprocessor → #use. These pages assume the explicit Klass.method(...) form because it’s the unambiguous reference style; in your own code, pick whichever you prefer.

ClassRoleWhere
FoundationObject-style value wrappers + first container (Number, String, Data, Array)generic/lib/
Stdioscreen output, cursor positioning, formatted printatari/lib/, commodore/lib/
Mathrandom numbers, square root, trig, log/exp/pow, constantsatari/lib/, commodore/lib/
TimeRTCLOK access, jiffy / second timing, busy-wait delaysatari/lib/, commodore/lib/
Heapheap allocator introspection (free, largest, total)atari/lib/
Vbiinstall / remove Vertical-Blank-Interrupt handlersatari/lib/
Systemprocess control (exit)atari/lib/, commodore/lib/
Asserttest-fixture assertion helpers; gated to no-ops by -DNDEBUG / -DRELEASEgeneric/lib/
Sortin-place quicksort with a user-supplied comparatorgeneric/lib/

The graphics classes (Gfx, Gfx6/7/8/15, GfxFactory), FILE, and the mapData / symbols helpers aren’t on the site yet — they will land in a follow-up pass.

A note on overload resolution by return type

Section titled “A note on overload resolution by return type”

xtc supports overloading by return type for zero-arg static methods, and the standard library exploits this for Math.rand() and the math constants. auto x = Math.rand(); is ambiguous; the compiler needs to know what type you want:

u8 a = Math.rand(); // resolves to the u8 overload
u16 b = Math.rand(); // resolves to the u16 overload
float c = Math.rand(); // resolves to the float overload
double d = Math.rand(); // resolves to the double overload

Same for Math.PI(), Math.E(), etc. — each has a float-returning and a double-returning overload, picked by the receiving variable’s type.