NOOK
A safe and comfortable systems language.
- ✅ Tokenizer
- ✅ AST Parser
- ❌ Static Analysis
- ❌ Code Gen
pkg main;
struct Point {
var x: f64;
var y: f64;
// Statically dispatched, can read member fields
const magnitude = () -> f64 {
return (.x ** 2.0 + .y ** 2.0) ** 0.5;
}
}
var origin = Point {
x: 0.0,
y: 0.0,
};
var far: own<Point> = new Point {
x: 3.0,
y: 4.0,
};
if (far.magnitude() > 1.0) {
print "far from origin";
} else {
print "close";
}
drop far;- Allocation is explicit. Locals live on the stack, globals in static storage, and the heap is reached only through
new, which yields anown<T>. - Functions are just values.
constgives static dispatch,vargives dynamic. - References are ephemeral. A
ref<T>is usable within an expression and can never escape its owner.