The oxl language
A taste of v0:
package main
struct Point { x: int, y: int }
fn fail(b: bool) -> [int, err] { if b { return 0, 1 } return 42, nil}
fn main() { [v, err] = fail(false) if err != nil { return } println(itoa(v))
ch := mkchan() scope { spawn send(ch, 7) println(itoa(recv(ch))) }}The surface
Section titled “The surface”- Types:
int float bool byte str cstr err chan, userstructs,enumtagged unions withmatch, slices[]T, function values and closures, and methodsfn (r T) m.byteis a distinctu8with char-literal sugar andasconversions. - Ownership:
own T/ref T/mut Thandles with runtime borrow checks and compile-time move tracking;deferfor cleanup;extern fnfor C FFI. - Errors:
[v, err]returns; a dropped error is a compile error. Errors carry text through an interned message registry (errors.new(msg),errors.msg(e),errors.code(e)). - Concurrency:
scope/spawn/goplusspawnBlockingon a worker and blocking pool; suspend-capable functions compile to stackless state machines; buffered channelsmkchan(n)andselectmulti-channel wait. - Generics:
fn f[T any]andfn g[T cmp.Ordered]with dotted interface constraints (interfaceop constraints), monomorphized per call site. - Control flow:
if/match/for,break/continue, top-levelletglobals (process-wide state, initialized beforemain). - Builtins:
print,itoa, string ops,mkbuf/poke*,argc/argv,readfile/writefile,exit,mkshared/sget/sset/scas/sadd,now/now_ms/usleep, sqlite3 shims,assert.
The standard library
Section titled “The standard library”std/ ships next to the toolchain binary; pull in a package with
import "std/<pkg>" (as aliases and .{name, ...} selection
supported). The v0.4 line ships 39 packages:
- Text:
std/strings(startswith/contains,trim,split,join, case ops),std/strconv,std/unicode/utf8,std/regexp(Thompson NFA engine, linear-time matching) - I/O and files:
std/io,std/bytes,std/bufio,std/fmt,std/errors,std/path,std/path/filepath,std/os(args, files, fs primitives, env),std/os/exec(processcmd/run/output) - Tooling:
std/flag,std/log,std/testing(assertions foroxl test),std/time,std/sync - Data and algorithms:
std/collections,std/container/{heap, list,ring},std/sort,std/slices,std/maps,std/cmp(theOrderedconstraint generics bind on),std/math,std/math/rand - Encoding and crypto:
std/encoding/{json,base64,hex,binary,csv},std/hash,std/crypto/{sha256,md5,hmac} - Networking:
std/net(dial/listen),std/net/http(server plus client get/post)
Modules
Section titled “Modules”Packages are directories of .oxl files that share a package clause;
package main marks an executable. A project opts into module mode by
placing an oxl.mod manifest at its root; the language walks up from
the entry file to the nearest one, and without it only std/ imports
resolve (the version-manager shim looks the pin up from the current
working directory instead — a build run from outside the project tree
can resolve a different pin or the default):
module github.com/me/app
oxl 0.3
require github.com/oxidean/widget v1.4.2replace github.com/oxidean/widget => ../widgetDirectives: module (this module’s path), oxl (minimum toolchain
version), require (a dependency at a version, also in a parenthesized
block), replace (pin a dependency to a local directory), and
toolchain (toolchain pin — parsed by the language, consumed by the
version-manager shim).
Import resolution runs one longest-prefix competition across every
candidate tree: std/... (the shipped standard library), this module’s
path (resolved under the manifest’s directory), used workspace trees,
replace directories, and required modules in the module cache at
$OXLMODCACHE or ~/.oxl/mod. Longest matching path wins; an exact tie
goes to the earlier source, and a used module shadows a require on
the same path. Packages under internal/ may only be imported by code
beneath the internal directory’s parent, import cycles are a compile
error that prints the cycle chain, and an import the file never
references doesn’t build either.
An oxl.work file (oxlwork 0.3 plus use lines naming module
directories relative to the work file, discovered by walking up from
the entry) stitches several local modules into one build — imports under
a used module’s path resolve to the local tree ahead of replace and
the cache, an exact-path tie goes to the use tree, and used modules
need no cache slots or oxl.sum entries. File mode (no oxl.mod found)
ignores workspaces entirely. The oxl repo itself is one: packages outside
std/ live in extra/ (module github.com/oxidean/oxl/extra), wired
through the root oxl.work.
oxl get <path>@<query> fetches a module through git, doing a bare
clone plus git archive of the resolved commit (canonical tree bytes,
never a checkout), into a read-only content-addressed cache, upserts the
require line, and pins h1: hashes in oxl.sum. Every build verifies
cached modules against oxl.sum; queries are @latest, @vX.Y.Z, or a
branch/SHA recorded as a pseudo-version v0.0.0-<timestamp>-<sha>.
replace directories bypass cache and sums by design, and private repos
work through git’s own auth.
oxl mod keeps oxl.mod/oxl.sum in sync so neither is edited by hand:
oxl mod init <path> writes a skeleton manifest (refusing to overwrite),
oxl mod tidy walks the import graph and rewrites surgically (comments,
replaces, and untouched lines survive; unimported requires drop),
oxl mod verify re-hashes every required module’s cache slot against
oxl.sum, and oxl mod list prints the MVS-selected build list like
oxl list -m all.
The references live in the repository:
docs/semantics/
covers ownership, concurrency, and the per-feature contracts everything is
built against, and the
approved design spec
is what everything traces back to.