Types
Primitives
- Int (Int8, Int16, Int32, Int64, IntU8, IntU16, IntU32, IntU64)
- Float (Float32, Float64)
- Char (Char8, Char16)
- Bool
- Void
Dynamic structures
- List[T]
- Dynamic list of elements of type T
- Map[K, V]
- Dynamic map of keys of type K, and values of type V
- Using V=Void makes it essentially a set
Other features
-
@- Reference instead of copy
-
?- Optional (can be
null)
- Optional (can be
-
Type1(<paramX:TypeX>*)- Callable with params
- Example Int(x: Int, y: Int) - a function with parameters x: Int, and y: Int, which returns Int
Example type usage (Complex module)
module Complex
struct Complex
re: Float
im: Float
end
func conjugate -> Complex(c: Complex)
return Complex {
re=c.re,
im=-c.im,
}
end
cast -> Complex(f: Float)
return Complex {
re=f,
im=0.0,
}
end
cast -> Complex(i: Int)
return Complex {
re=Float {i},
im=0.0,
}
end
operator["+"] → Complex()
end