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.
Comments start with # and run to the end
of the line.
๐ค 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!
โจ๏ธ Input And Conversion
read_text / leggi_testo
Input Arity: 0Description: Reads one line from standard input and returns it as text.
Example:
set "line" read_text
print get "line"
Error/Edge Behavior:
At EOF, read_text returns "" (empty string).
to_number / numero_da_testo
Conversion Arity: 1Description: Converts text to a number using Lua numeric parsing rules.
Example:
print to_number "42" โ 42
print add to_number "7" 5 โ 12
Error/Edge Behavior:
print to_number "abc" โ nil
add to_number "abc" 5 โ Lua runtime error (arithmetic on nil)
โ 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.
nil / nullo
Logic Arity: 0Description: Returns the value nil (no value).
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 $x 10 {
print " x is 10 "
print " doing something "
} {
print " x is not 10 "
}
cond
Control Flow Arity: 1
Description: Multi-way conditional. Takes a block of
condition result pairs and returns the result of the first
truthy condition. Use else (or true) as the
final condition for a default.
Example:
cond {
not greater @1 59 "F"
not greater @1 79 "C"
else "A"
}
else / altrimenti
Control Flow Arity: 0
Description: Returns true. Used as the default clause
in cond.
while / mentre
Control Flow Arity: 2Description: Loop that executes body while condition remains true.
Example:
i= 1
while not greater $i 5 {
print $i
i= add $i 1
}
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 get "temp" get "temp"
end
print get "result" โ 25
return / ritorna
Control Flow Arity: 1
Description: Returns a value from the enclosing
function definition. Use return nil for no value.
Example:
define_word "square" 1 {
return multiply @1 @1
}
print square 5 โ 25
break / interrompi
Control Flow Arity: 1
Description: Exits the innermost loop and returns
<value> from it. Use break nil for no
value. Only valid inside a loop in the same function.
Example:
i= 1
while not greater $i 20 {
if equal 0 modulus $i 3 {
break $i
}
i= add $i 1
}
print $i โ 3
continue / continua
Control Flow Arity: 0Description: Skips the rest of the current loop iteration and continues with the next one. Only valid inside a loop in the same function.
Example:
i= 0
while not greater $i 5 {
i= add $i 1
if equal 0 modulus $i 2 {
continue
}
print $i
}
๐ฆ 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 quoted strings for variable names and literal text.
get / prendi
Variables Arity: 1Description: Retrieves the value of a variable from the current scope.
Example:
set "x" 42
print get "x" โ 42
sugar: $name / name= / @index / { }
Variables Sugar
Description: $name is shorthand for
get "name", name= value is shorthand for
set "name" value, @index is shorthand for
argument index, and { / } are
shorthand for do / end.
Example:
x= 10
print $x โ 10
y= add $x 5
print $y โ 15
Note: Language-agnostic (works with
prendi/metti in Italian). Quoted strings are
unaffected: print "$x" prints the literal $x.
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 @1 @1
define_word "sum3" 3
add @1 add @2 @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
String literals
Special SyntaxDescription: String literals are always quoted and are never evaluated as words.
Example:
set "x" "hello"
get "x"
print "line1\nline2"
print "quote: \"ok\""
Supported Escapes:
\"for quote\\for backslash\nfor newline\tfor tab
dont / non_fare
Special Arity: 1
Description: Consumes one argument but does nothing.
Used to comment out code or create no-op placeholders. For a simpler
no-op, use pass (see below).
Example:
dont print " This won't be executed "
print " But this will "
pass / passa
Special Arity: 0
Description: No-op word that does nothing. A cleaner
alternative to dont nothing for empty branches.
Example:
if true
pass
print " not executed "
string / stringa
Special RemovedDescription: Legacy keyword removed. Use quoted literals directly.
Example:
print "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