Lua Playground
Write Lua, run it on the BEAM, and watch the register-based bytecode this VM actually executes. No JavaScript Lua. Every byte is Elixir.
Language
Security & limits
Errors
Your first Lua program on the BEAM.
Output
idle
Hit Run
or press ⌘ ↵
to execute.
Reading the arguments
r0,r1, …- register slots — scratch space the VM uses for locals and temporaries
up[0]- upvalue — a variable captured from the enclosing function
_G["x"]- global variable named
x proto[0]- a nested function definition inside this one
"foo",42- a constant literal baked into the bytecode
multi(n)- multiple return values (n of them)
...- varargs — the rest of the arguments
Bytecode · Lua.Compiler.Prototype
1 proto
params
0
vararg
yes
registers
4
upvalues
0
Hover a row to highlight every instruction from the same source line. Click to jump the editor there.
| PC | Line | Instruction |
|---|---|---|
| 000 | load_env r0 | |
| 001 | L1 | source_line line 1 |
| 002 | L1 | get_open_upvalue r1, r0 |
| 003 | L1 | get_field r2, r1.print |
| 004 | L1 | move r1, r2 |
| 005 | L1 | load_constant r3, "Hello, Lua on the BEAM!" |
| 006 | L1 | move r2, r3 |
| 007 | L1 | call r1, args=1, results=0 |
| 008 | L2 | source_line line 2 |
| 009 | L2 | load_constant r1, 42 |
| 010 | L2 | return r1, count=1 |
Run
⌘ + ↵
Indent
Tab / Shift
+ Tab
Heads-up
Snippets run in a sandboxed VM with a 1.5s timeout.