Language Reference
Complete reference of all built-in words in Pangea. Each word is shown with its English and Italian name.
Notation
Arity refers to how many arguments a word takes.
<angle brackets> indicate required arguments.
📤 Output
print / stampa
Output Arity: 1Description: Evaluates and prints the value to standard output, followed by a newline.
Example:
print 42
print add 5 6
print " Hello, World! "
Output:
42
11
Hello, World!
➕ Arithmetic
add / somma
Arithmetic Arity: 2Description: Returns the sum of two numbers.
Example:
add 5 6 → 11
add -3 10 → 7
add add 1 2 3 → 6
multiply / moltiplica
Arithmetic Arity: 2Description: Returns the product of two numbers.
Example:
multiply 7 8 → 56
multiply 3 add 2 3 → 15
multiply -1 5 → -5
modulus / modulo
Arithmetic Arity: 2Description: Returns the remainder after division (modulo operation).
Example:
modulus 10 3 → 1
modulus 15 5 → 0
modulus 7 2 → 1
Use Case:
Check if a number is divisible by another:
equal 0 modulus 15 3 → true (15 is divisible by 3)
🔢 Comparison
equal / uguale
Comparison Arity: 2Description: Returns true if both values are equal, false otherwise.
Example:
equal 5 5 → true
equal 3 4 → false
equal " hello " " hello " → true
greater / maggiore
Comparison Arity: 2Description: Returns true if value1 > value2.
Example:
greater 10 5 → true
greater 3 7 → false
greater 5 5 → false
🔀 Logic
true / vero
Logic Arity: 0Description: Returns the boolean value true.
false / falso
Logic Arity: 0Description: Returns the boolean value false.
not / non
Logic Arity: 1Description: Logical negation. Returns the opposite boolean value.
Example:
not true → false
not false → true
not equal 3 4 → true
not greater 5 10 → true
🎯 Control Flow
if / se
Control Flow Arity: 3Description: Conditional execution. Evaluates condition, then executes either the then-branch or else-branch.
Example:
if greater 5 3
print " 5 is greater "
print " 5 is not greater "
With blocks:
if equal get x 10 do
print " x is 10 "
print " doing something "
end do
print " x is not 10 "
end
while / mentre
Control Flow Arity: 2Description: Loop that executes body while condition remains true.
Example:
set i 1
while not greater get i 5 do
print get i
set i add get i 1
end
Output:
1
2
3
4
5
do ... end / fai ... fine
Control Flow SpecialDescription: Groups multiple statements into a single expression. Returns the value of the last statement.
Example:
set result do
set temp 5
multiply temp temp
end
print get result → 25
📦 Variables
set / metti
Variables Arity: 2Description: Stores a value in a variable in the current scope.
Example:
set x 10
set name : Alice
set result add 5 6
Note: Use : to pass literal names without evaluation.
get / prendi
Variables Arity: 1Description: Retrieves the value of a variable from the current scope.
Example:
set x 42
print get x → 42
print get : x → 42
increment / incrementa
Variables Arity: 1Description: Increments a numeric variable by 1 and returns the new value.
Example:
set i 5
increment : i → 6
print get i → 6
🔧 Functions
define_word / definisci_parola
Functions Arity: 3Description: Defines a new word (function) with the specified name, number of arguments, and body.
Example:
define_word square 1
multiply argument 1 argument 1
define_word sum3 3
add argument 1 add argument 2 argument 3
print square 5 → 25
print sum3 1 2 3 → 6
argument / argomento
Functions Arity: 1Description: Accesses a function parameter by index (1-based).
Example:
define_word greet 2 do
print argument 1
print argument 2
end
greet " Hello " " World "
namespace
Functions Arity: 0Description: Returns the current function's namespace (variable table).
Example:
define_word test 1
variable_set namespace : x argument 1
test 42
📝 Advanced Variables
variable_set / metti_variabile
Advanced Arity: 3Description: Sets a variable in a specific namespace (scope).
Example:
variable_set namespace : x 100
variable_get / prendi_variabile
Advanced Arity: 2Description: Gets a variable from a specific namespace (scope).
Example:
print variable_get namespace : x
📄 File Operations
!
File Arity: 1Description: Executes the code in the specified file.
Example:
! : helper.words
! : ../tests/factorial.words
Note: File paths are relative to the current working directory.
🎨 Special Operators
: (colon)
Special Arity: 1Description: Returns the next word as a literal string without evaluating it.
Example:
set x : hello // Stores "hello", not the value of a word named hello
get : x // Retrieves x by name
print : " literal " // Prints "literal"
Use Cases:
- Variable names in set/get
- String literals
- Function names as data
dont / non_fare
Special Arity: 1Description: Consumes one argument but does nothing. Used to comment out code or create no-op placeholders.
Example:
dont print " This won't be executed "
print " But this will "
string / stringa
Special Arity: 1Description: Returns the word as a string value (similar to :).
Example:
print string hello → "hello"
❓ Utilities
?
Utility Arity: 0Description: Lists all defined words with their arities.
Example:
?
Output:
print<1 add<2 multiply<2 if<3 while<2 ...
exit / esci
Utility Arity: 0Description: Exits the REPL.
Example:
exit
🌐 Bilingual Reference Table
| Category | English | Italian | Arity |
|---|---|---|---|
| Output | stampa | 1 | |
| Arithmetic | add | somma | 2 |
| Arithmetic | multiply | moltiplica | 2 |
| Arithmetic | modulus | modulo | 2 |
| Comparison | equal | uguale | 2 |
| Comparison | greater | maggiore | 2 |
| Logic | true | vero | 0 |
| Logic | false | falso | 0 |
| Logic | not | non | 1 |
| Control Flow | if | se | 3 |
| Control Flow | while | mentre | 2 |
| Control Flow | do | fai | special |
| Control Flow | end | fine | special |
| Variables | set | metti | 2 |
| Variables | get | prendi | 1 |
| Variables | increment | incrementa | 1 |
| Functions | define_word | definisci_parola | 3 |
| Functions | argument | argomento | 1 |
| Special | dont | non_fare | 1 |
| Special | string | stringa | 1 |
| Special | exit | esci | 0 |
💡 Missing a Feature?
Pangea is intentionally minimal. Missing features include:
- Subtraction and division (use
add ... -Nfor subtraction) - I/O operations (read from stdin, write to files)
- Lists/arrays
- Dictionaries/maps
- String manipulation
- Break statement in loops
These can be added by defining new Lua functions in word_definitions.
⚠ Known Limitations
- No tail-call optimization (deep recursion may overflow)
- No garbage collection control
- Limited error messages
- Case-sensitive keywords
- File paths are relative to CWD, not script location