Language Tour
Types, operators, and control flow in AHA! — a 10-minute tour
Language Tour
Types
| Type | Notes |
|---|---|
Int | 64-bit integer — the universal numeric type |
Bool | true / false literals; produced by ! |
String | "..." with escape sequences (\n, \t, \\, \", \r, \0) |
Operators
| Category | Operators |
|---|---|
| Arithmetic | + - * / % |
| Comparison | == != < > <= >= (→ Int 0/1) |
| Logical | && || (→ Int 0/1) |
| Prefix | -x, !x |
| Assignment | x = value |
Boolean Algebra That Composes
All comparison and logical operators return Int 0/1 instead of a boolean — so logic results flow straight into arithmetic:
fn is_even(n) {
n % 2 == 0
}
print(is_even(4) * 100); // 1 * 100 = 100No casts, no conversions — logic just composes.
Variables
let count = 0;
count = count + 1; // assignment
count // 1Control Flow
if / else
if is an expression — the last expression of each branch is the value:
let x = 10;
let y = 20;
if x > y {
x
} else {
y
}while
let i = 0;
while i < 5 {
i = i + 1;
}
i // 5for
for loops over an integer range a..b (exclusive end):
let sum = 0;
for i in 0..10 {
sum = sum + i;
}
sum // 0 + 1 + ... + 9 = 45break / continue
let total = 0;
for i in 0..100 {
if i == 5 {
break;
}
total = total + i;
}
total // 0 + 1 + 2 + 3 + 4 = 10Comments
// line comment/* block comment */
Builtins
| Builtin | Description |
|---|---|
print(int) | Print an integer |
print_str(string) | Print a string |
len(string) | String length in O(1) |
abs(x), min(a, b), max(a, b) | Numeric helpers |
See Builtins for details.