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
Classic recursion. Watch the closure prototype and tail-calls in the bytecode.
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
2 protos
params
0
vararg
yes
registers
15
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 | closure r5, proto[0] |
| 003 | L1 | move r1, r5 |
| 004 | L1 | set_open_upvalue r1, r5 |
| 005 | L6 | source_line line 6 |
| 006 | L6 | load_constant r8, 0 |
| 007 | L6 | load_constant r9, 10 |
| 008 | L6 | load_constant r10, 1 |
| 009 | L6 | move r5, r8 |
| 010 | L6 | move r6, r9 |
| 011 | L6 | move r7, r10 |
| 012 | L6 | numeric_for r5 |
| 013 | L10 | source_line line 10 |
| 014 | L10 | get_open_upvalue r5, r1 |
| 015 | L10 | load_constant r7, 15 |
| 016 | L10 | move r6, r7 |
| 017 | L10 | call r5, args=1, results=-1 |
Run
⌘ + ↵
Indent
Tab / Shift
+ Tab
Heads-up
Snippets run in a sandboxed VM with a 1.5s timeout.