Language Reference
This is the complete reference for the mimas language, version 0.1.0. It describes the syntax and semantics of the language itself — the parts you write in a .mim file. Extending mimas from Rust is covered separately in Extension with Rust.
mimas is a statically typed, embeddable scripting language for Rust. It borrows much of Rust’s syntax and ergonomics and reshapes the rest to deliver what a scripting layer is good for: fast iteration, quick compile times, and runtime flexibility.
enum Shape {
Circle(float),
Rect(float, float),
}
fn area(s: Shape) -> float {
match s {
Shape::Circle(r) => 3.14159 * r * r,
Shape::Rect(w, h) => w * h,
}
}
let shapes = [Shape::Circle(2.0), Shape::Rect(3.0, 4.0)];
let total = for s in shapes collect area(s);
print(f"areas: {total}"); // areas: [12.56636, 12]
How to read this reference
Each page introduces one concept with short, runnable examples. Every snippet here is real mimas; you can drop one into a file and run it:
mimas example.mim
A few conventions used throughout:
- We annotate types liberally (
let a: int = 0) to make each example’s behavior explicit. In practice mimas infers most of them — you only need annotations on function signatures and type declarations. See Variables. - A
// ->comment shows what an expression evaluates to or whatprintoutputs. - A
// compile error: …comment marks code that is intentionally rejected, with the reason the compiler gives.