Basic API Reference
Compiler CLI
| Command | Purpose |
|---|
thagc build <file.tg> -o <bin> | Compile source to native executable |
thagc run <file.tg> | Build and run |
thagc check <file.tg> | Validate parse/type/codegen without final link |
thagc fmt <file.tg> | Normalize source formatting |
Dependency, registry, and update flows are handled by drago.
Build/link flags
| Flag | Meaning |
|---|
--target=<triple> | Build for configured target triple |
--emit-llvm | Emit .ll IR instead of linking binary |
--link-lib=<name> | Add -l<name> to linker |
--link-dir=<path> | Add -L<path> to linker |
--link-arg=<arg> | Pass raw linker argument |
Shipped stdlib modules
| Module | Import | Key functions |
|---|
std.io | import std.io as io | read_line, read_int, read_ints, read_word, read_all |
std.math | import std.math as math | abs, min, max, clamp, sqrt, pow, gcd, lcm |
std.string | import std.string as string | concat, from_int, to_int, from_f64, split, trim, contains |
std.time | import std.time as time | now_ms, sleep_ms |
The following modules do not exist: lib.fs, lib.process, lib.env, lib.http, lib.toml, lib.tensor, lib.map.
Builtins (no import needed)
| Name | Signature | Description |
|---|
print | print(value) | write str, bool, i32, i64, or f64 to stdout without newline |
println | println(value) | write str, bool, i32, i64, or f64 to stdout with newline |
eprint | eprint(value) | write str, bool, i32, i64, or f64 to stderr without newline |
eprintln | eprintln(value) | write str, bool, i32, i64, or f64 to stderr with newline |
flush | flush() | flush stdout |
extern func symbol_name(arg1: i32, arg2: ptr) -> i32
- Signature must match the C symbol ABI exactly.
- Use
str for const char*, ptr for void*, f64 for double.
- There is no
f32 type available to user code.
- Add explicit link flags (
--link-lib, --link-dir) for external libraries.
See FFI Safety Guidelines for the full checklist.