The tables below are for looking something up at a glance. For the exact shape
of every construct, see the Grammar.
| Keyword |
Purpose |
class |
Declare a class |
interface |
Declare an interface |
enum |
Declare an enum |
fn |
Declare a function or method |
extends |
Inherit from a class |
implements |
Fulfill one or more interfaces |
super |
Call the parent’s init |
self |
Reference the current instance |
static |
Declare a class-level member |
local |
Declare a private member or variable |
export |
Make a file member publicly importable |
import |
Import from another file |
return |
Return a value from a function |
throw |
Raise an error |
try |
Begin an error-handled block |
catch |
Handle a thrown error; several clauses are tried in order |
finally |
Run on every way out of a try |
for |
Begin a loop |
while |
Begin a while loop |
repeat |
Begin a repeat-until loop |
until |
End condition for repeat loop |
break |
Exit a loop |
continue |
Skip to the next iteration |
if / elseif / else / end |
Conditional logic |
match |
Begin a pattern-matching expression |
case |
Introduce a pattern arm inside match |
when |
Attach a guard condition to a case, or start a when(...) pipeline |
then |
Begin a match arm body / if branch |
nil |
Absence of value |
true / false |
Boolean literals |
| Literal |
Type |
Notes |
42 |
integer |
|
0xFF, 0b1010 |
integer |
_ may separate digits: 0xFF_80_00 |
3.14 |
float |
|
.5 |
float |
The integer part may be omitted |
10f, 10F |
float |
Suffix form of 10.0 |
1e9, 2e-7, 6.022E+23 |
float |
Exponent: ×10ⁿ, always a float |
"text" |
string |
|
true, false |
boolean |
|
nil |
— |
Only assignable to a nullable (T?) slot |
| Operator |
Meaning |
?. |
Safe member access |
?[ ] |
Safe index |
?? |
Null coalescing fallback |
! |
Force unwrap nullable |
.. |
String concatenation |
# |
Length of a table, string (codepoints) or bytes (bytes) |
==, != |
Equality checks |
>, <, >=, <= |
Comparisons |
and, or, not |
Boolean logic |
+, -, *, /, % |
Arithmetic (/ on two integers truncates) |
^ |
Exponentiation (right-associative, binds tighter than unary -) |
&, |, ~, <<, >> |
Bitwise and / or / xor / shifts — integer only |
~a |
Bitwise complement (prefix ~; infix ~ is xor) |
+=, -=, *=, /=, %=, ^=, ..=, &=, |=, <<=, >>= |
Compound assignment (no ~= — that is Lua’s !=) |
: |
Pipeline stage call inside when(...) |
as |
Cast — converts a typed value (x as integer truncates toward zero, n as string renders), tests an any |
| Form |
Meaning |
Coroutine.create(fn(co) … end) |
A new, not-yet-started Coroutine<T>; co is its Yielder<T> |
co.yield(v) |
Suspend, handing v to whoever resumed |
gen.resume() |
Run to the next yield; T?, nil once done or failed |
for v in gen do … end |
Resume until finished; v is a T |
gen.status() |
"suspended", "running", "normal" or "dead" |
gen.isDone() / gen.error() |
Dead yet? / Why it failed, or nil |