Swift-like strongly typed language that compiles to JavaScript.
- Custom operators
- Type inference
- Enums
- Inout (pass by reference)
- Classes
- Arrays
- Structs
- Bootstrapping
- Operator overloading
- Optimizations (Tree shaking, variable folding..)
- Restrict inout possibilities ewww
let a = 7
let b = 42
infix operator swap {
associativity left
precedence 120
constructor(lhs: inout Int, rhs: inout Int) {
const tmp = lhs
lhs = rhs
rhs = tmp
}
}
a swap b;
class Vector {
let x = 0
let y = 0
constructor(x:Int, y:Int) {
this.x = x
this.y = y
}
}
infix operator equals {
associativity left
precedence 90
constructor(left:Vector, right:Vector)->Boolean {
return (
left.x == right.x &&
left.y == right.y
)
}
}
let vecA = Vector(2, 2)
let vecB = Vector(4, 4)
vecA equals vecB // false
func fibonacci(n:Int) {
if n == 0 || n == 1 {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}