Release Notes
Added
- The outside world: basic I/O. Five builtins for reading and writing the
world beyond the program, each one fallible the same way lux already teaches.
readFile(path) returns Result<string, string> and writeFile(path, contents) returns Result<Unit, string>, so a missing file or a failed write
comes back as a value you match, never a surprise. args() returns the
command line as [string], the program itself at index 0. readLine() returns
Option<string> — a line, or none at the end of input — so a loop over it
reads the same whether a person is typing or a file is piped in. eprint(...)
writes to stderr, beside the existing print on stdout, so a program's output
stays clean for the next program to read.
Unit is now a spellable, matchable type. writeFile's success carries
nothing, so its type is Result<Unit, string>; Unit validates as a type name
and a value still prints as nothing.
lux learn io — a new topic card and more page covering the outside
world, added as the capstone of the safety guided lesson, with new rows in
the graduation ladder.
Changed
- All five I/O builtins translate through every backend: Rust's
std::fs /
std::env / eprintln!, Go's os package handing back its (value, error)
pairs, and Swift's Foundation with its throwing file calls and native
readLine(). Generated Go now lowers a Result match to an if-init
(if text, err := readFile(p); err == nil), so two reads in one block no
longer collide on their names — also the more idiomatic Go.
Install lux 0.4.0
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/anderix/lux/releases/download/v0.4.0/lux-installer.sh | sh
Download lux 0.4.0