Repository navigation
Language Reference
0x4171341 edited this page Jul 23, 2026
·
4 revisions
as break continue def else enum false fn for from if import in match mut pub return spawn struct true while
| Type | Description | Example |
|---|---|---|
Int |
64-bit signed integer |
42, 0, -1 (via 0 - 1) |
Float |
64-bit IEEE 754 |
3.14, 0.0
|
Str |
ARC-managed string | "hello" |
Bool |
Boolean |
true, false
|
Void |
No return value | (default for functions) |
List[T] |
Dynamic list | list_new() |
Map[K,V] |
Hash map | map_new() |
| Custom | Struct/Enum type |
Point, Color
|
x := 42 # immutable, type inferred
mut y := 0 # mutable
y = 10 # reassign (requires mut)
name := "Alice" # Str
def add(a: Int, b: Int) -> Int:
return a + b
def greet(name: Str): # returns Void
print_str(name)
struct Point:
x: Int
y: Int
p := Point(10, 20)
print(p.x) # 10
enum Color:
Red
Green
Blue
enum Result:
Ok(value: Int)
Err(code: Int)
c := Color.Red
r := Result.Ok(42)
e := Result.Err(1)
match value:
Ok(v):
print(v)
Err(code):
print(code)
Red:
print_str("red")
def process(x: Int) -> Int:
v := might_fail(x)? # ? unwraps Ok or returns Err
return Result.Ok(v + 1)
# If/else
if x > 0:
print_str("positive")
else:
print_str("non-positive")
# While
mut i := 0
while i < 10:
print(i)
i = i + 1
# For range
for i in range(10):
print(i)
# For list
for item in lst:
print(item)
# Break/continue
while true:
if done:
break
adder := fn(x: Int) -> Int:
return x + 10
result := adder(5) # 15
spawn fn():
print_str("in thread")
| Operator | Description |
|---|---|
+ - * / %
|
Arithmetic |
== != < > <= >=
|
Comparison |
:= |
Declare (immutable) |
= |
Assign (requires mut) |
? |
Try/unwrap Result |
. |
Field access / enum variant |