Language Reference
Language Rules
Variables, types, scope, functions, operators - all the rules in one place.
Variables
Naming
- Must start with a letter or underscore
- Can contain letters, numbers, underscores
- Case-sensitive:
myVar ≠ myvar ≠ MYVAR - Cannot be a keyword, builtin name, or defined function name
Assignment Operators
| Syntax | Example |
|---|---|
x = 5 | Standard equals |
x := 5 | Walrus-style |
x <- 5 | Arrow assignment |
set x to 5 | English style |
let x be 5 | English style |
store 5 in x | English style |
x is 5 | Valid only at top level (not inside conditions) |
Types
| Type | Example | Notes |
|---|---|---|
number | 42, 3.14, -1 | Integers and floats - no distinction |
string | "hello", 'world' | Both quote styles accepted |
bool | true, false | Lowercase only |
null | null | Absence of value |
list | [1, 2, 3] | Ordered, mixed types ok |
Scope
pseudo
x = 10 # global
myFunc()
print x # ✓ reads global (fine)
x = 20 # creates a NEW local x - does NOT touch global
myFunc()
x # → still 10Global keyword
pseudo
counter = 0
increment()
global counter # explicit declaration
counter = counter + 1
increment()
increment()
counter # → 2Functions
Definition
pseudo
# All equivalent function definitions:
bubbleSort(arr)
func bubbleSort(arr)
function bubbleSort(arr)
define bubbleSort(arr)
algorithm bubbleSort(arr)
recursive fibonacci(n)Define vs Call
pseudo
sort(arr) # CALL - if sort is in symbol table, no body follows
sort(arr) # DEFINITION - if indented body follows below
sort([3,1,2]) # always CALL - literal argumentTwo-pass parsing
Pass 1 scans all function names before execution. This enables mutual recursion - functions can call each other without forward declarations:
pseudo
isEven(n)
if n == 0: return true
return isOdd(n - 1)
isOdd(n)
if n == 0: return false
return isEven(n - 1)
isEven(4) # → trueOperators
| Category | Operators |
|---|---|
| Arithmetic | + - * / // % ** (also ^ and power) |
| Comparison | > < >= <= == != - also greater than, equals, etc. |
| Logical | and or not - also && || ! |
| Ternary | cond ? true_val : false_val |
| String | + concat, * repeat, str[i], str[a:b] |
| List | + concat, arr[i], arr[-1], arr[a:b] |
Ternary
pseudo
x = n > 10 ? "big" : "small"
print (n > 0 ? "positive" : "non-positive")String Interpolation
pseudo
name = "Alice"
print "Hello, {name}!" # → Hello, Alice!
print "Result: {score * 2}" # → Result: 190
print "Pi: {round(pi, 2)}" # → Pi: 3.14
# Escape: \{ \} → literal bracesComments
pseudo
# single line comment
x = 5 # inline comment
# multi-line: just stack them
# line 1
# line 2Indentation
- Spaces or tabs - never mixed in the same file
- Any consistent size: 2, 4, or 8 spaces
- Mixed tabs/spaces →
IndentationError
Auto-print
pseudo
x = 42
x # → prints 42 (bare variable)
len([1,2,3]) # → prints 3 (bare function call)
# These are SILENT:
result = func() # assignment
x = 5 # assignmentError Handling
pseudo
try
x = 1 / 0
catch ZeroDivisionError
print "cannot divide by zero"
finally
print "this always runs"Built-in Error Types
| Error | When |
|---|---|
ZeroDivisionError | Dividing by zero |
IndexError | List index out of bounds |
TypeError | Wrong type for operation |
ValueError | Right type, wrong value |
NameError | Undefined variable or function |
RecursionError | Max recursion depth (1000) exceeded |