Reference
Everything the language has. Read out of the compiler, not from memory: the keyword table below comes from src/rust-compiler/lexer.rs, the reserved names from src/rust-compiler/typeck.rs, the commands from src/rust-compiler/main.rs, and every standard-library entry from the // prose written above the declaration itself. scripts/site-reference.py regenerates these pages and a test diffs them, so this cannot fall behind the language again — which it had: the page this replaces still listed record, a keyword renamed eleven versions earlier.
- Builtins 33 calls the language owns, and what each needs
- The command line 10 commands, including
reviewandmcp-schema lib/option.bxabsence, made explicitlib/result.bxfailure, made explicitlib/decimal.bxthe helpers a money language is judged onlib/string.bxStrings, beyond the four builtinslib/array.bxthe operations on a growable array that every program reaches forlib/set.bxmembership, without a value nobody readslib/map.bxa key-value table, in insertion orderlib/math.bxinteger arithmetic that does not lie about its edgeslib/fn.bxthe four interfaces that stand in for a function valuelib/json.bxJSON, parsed and rendered, in ordinary Burxtlib/csv.bxcomma-separated values, read and written, RFC 4180 with thelib/html.bxHTML as a typed tree, escaped at the one point it leaveslib/cgi.bxthe request in, the response out, over the interface every web server haslib/bmx.bxBMX 0.1, parsed into a typed treelib/encoding.bxhex, base64 and base64url, and every decoder REFUSES rather than guesseslib/hash.bxhashes and checksumslib/secure.bxbytes nobody can predict, and a comparison that does not leaklib/vector.bxvector similarity, EXACTLYlib/files.bxfiles, without writing `external function fopen` yourselflib/path.bxPOSIX paths, taken apart and put back together, lexicallylib/os.bxthe machine the program is running onlib/net.bxTCP, over the pointer walllib/time.bxdates and durations, in whole seconds, in UTClib/random.bxa SEEDED generator, and the name says seededlib/log.bxfour levels, a threshold from the environment, and stderrlib/test.bxtesting Burxt, in Burxt- BMX the markup format — its own guide, spec and conformance suite
Keywords
The 41 words the lexer knows. Every one of them is the word it means: function, not fn; mutable, not mut.
let |
mutable |
const |
print |
print_error |
while |
function |
external |
return |
as |
tail |
pure |
public |
break |
continue |
if |
else |
true |
false |
class |
private |
region |
enum |
match |
interface |
is |
self |
implement |
implements |
for |
in |
dynamic |
Int |
Bool |
String |
CInt |
CPointer |
CDouble |
Decimal |
RoundHalfEven |
RoundHalfUp |
Contextual markers
Recognised only where they appear — on a signature, inside a clause — so a variable may still be called ensures anywhere else.
| Marker | What it says |
|---|---|
allocates |
This function builds values in its CALLER’s region. Optional and inferred since v0.0.142; writing it is still legal and still checked. |
requires |
A precondition. Checked, and it names itself when it fails. |
ensures |
A postcondition. result and old(...) are in scope inside one. |
decreases |
A measure that must fall on every recursive call, so the recursion ends. |
touches |
What the function may reach: files, commands, clock, input, network, model. It travels up the call chain. |
scaled |
In as scaled, at the C boundary — the only conversion that moves a Decimal across it. |
it |
The subject of a contract bracket: Int [> 0, <= it * 2]. Special ONLY inside a bracket. |
Spellings that do not compile
Reserved so the compiler can name the replacement rather than say unexpected identifier. Each of these is an error that tells you the word to write instead.
| Written | Burxt spells it |
|---|---|
fn |
function |
mut |
mutable |
impl |
implement |
dyn |
dynamic |
extern |
external |
struct |
class |
trait |
interface |
record |
class |
Types
| Type | What it is |
|---|---|
Int |
Signed 64-bit. Traps on overflow, never wraps |
Bool |
true / false. No coercion to or from anything |
String |
Bytes, NUL-terminated. len counts bytes |
Decimal<S> |
An integer scaled by 10^S, exact. S up to 18 |
Decimal<S, R> |
The same, carrying a rounding contract: RoundHalfEven or RoundHalfUp |
[T; N] |
Fixed array. The length is part of the type. Bounds always checked |
[T] |
Growable array. Lives in a region. Bounds always checked |
dynamic Named |
An interface object: a value plus the interface’s method table |
CInt, CDouble |
C’s widths. Only in an external function signature |
i32, u8, u32, u64 |
Sized C integers, boundary-only. A value that does not fit traps at the call rather than wrapping. u64 is checked against Int’s signed maximum, because Burxt has no wider integer to receive the top half |
Operators
| Operator | On | Notes |
|---|---|---|
+ - |
Int, Decimal of the SAME scale, String (+ only) |
Scales must match. A rounding contract on one side is carried into the result; two different contracts are refused |
* |
Int, Decimal × Int, Decimal × Decimal | Mixed Decimal scales need a rounding contract |
/ |
Decimal only | Always needs a rounding contract. Int / Int is refused — use divide_floor or divide_toward_zero |
== != |
Any two values of the same type | One equality, no coercion. Strings compare by bytes |
< <= > >= |
Int, Decimal | Same type both sides. On String it is refused |
&& \|\| |
Bool | Short-circuit: the right side runs only if it is needed |
! |
Bool | |
unary - |
Int, Decimal | Checked, like every other arithmetic |
+= -= *= |
Anything the long form allows | x += e IS x = x + e by the time it is checked. Works on a name, a field and an array element. There is deliberately no ++ |
? |
Result<T, E> |
f(x)? returns the failure unchanged, or unwraps the success |
Shorthands
The whole list. Burxt has few on purpose, and each is sugar over something it already means rather than a second way to mean it.
| Written | Means |
|---|---|
$19.99 |
19.99 as a Decimal<2>. The $ is documentation, not arithmetic |
8.25% |
0.0825 as a Decimal<4> — a percent is two scales finer than the number it is written as |
"total: {amount}" |
"total: " + to_string(amount) — and inside a print, the pieces go out in order with nothing built |
x += e |
x = x + e. Also -= and *=, on a name, a field, or xs[i] |
P { x, y } |
P { x: x, y: y } — a field taking a variable of the same name |
f(); |
a call kept for its effect, with no binding |
function (self) m() |
function (self: Type) m(), inside a block whose header already said which type |
P { x: 1, } |
a trailing comma, anywhere a list is written, so adding an item is a one-line diff |
let x = e; |
let x: T = e; where T is e’s type. Arrays are the exception — a literal does not say fixed or growable |
for x in xs { } |
let mutable i = 0; while i < len(xs) { let x = xs[i]; … } — xs must be a name or a field path |
for i in 0..n { } |
let mutable i = 0; while i < n { … } — the end is exclusive, i is immutable, and both bounds are Ints evaluated once. There is no ..=, and a range is not a value |
f(x)? |
match f(x) { Error(e) => return Error(e), Ok(v) => v } — the failure variant found by name, never converted |
Int [> 0, <= n] |
requires clauses written on the value instead of under the signature |
What stops a running program
| What happens | When |
|---|---|
arithmetic overflow — the exact result no longer fits in the value range |
+ - * on an Int or a Decimal past its range |
| an index out of range | xs[i] outside 0 .. len(xs) - 1 |
| a broken precondition, quoted back with the clause that failed | a requires that does not hold at a call |
| a broken postcondition | an ensures that does not hold at a return |
a decreases measure that did not decrease |
a recursion that would not have ended |
| dividing by zero | divide_floor, divide_toward_zero, remainder |
cannot cross as a C double exactly |
a value going out through CDouble that a double cannot hold |
Every one of them ends the program, and every one names itself. Nothing here is a warning, and nothing continues with a wrong value.
Not present, each for a reason
Block comments (/* … */) — line comments only, so there is no nesting rule to get wrong. Multi-line string literals — a literal spanning lines makes its own indentation part of the data, which is the one thing that surprises everybody about them; use \n and +. for i in 0..n — a range is a second construct, and while i < n says it. for x in text — a String is bytes, and byte_at says BYTE so the byte-versus-character question cannot hide. x++ — an expression with a side effect. a ? b : c — if as an expression would make it redundant. Arrow functions — they are closures, and captured state needs an owner.