Reflecto
A stack language drawn as a room of mirrors.
QuantumV, 2025 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 7 known programs · Test method
Run it
The idea
QuantumV made Reflecto in 2025, after Befunge and ><>. The program is a grid of characters. The pointer starts in the top-left corner going right and keeps moving, one cell at a time. Mirrors turn it, and every other command works on one stack of whole numbers with one register beside it.
Read the story
There is no jump and no loop command. A loop is a closed path of mirrors. The only test is !, which pops a number and skips the next cell when that number is 0. So a branch is a skip over a mirror.
The machine
| Char | Does |
|---|---|
/ \ | Turn the pointer as a mirror would |
| _ | Send back what meets it sideways, or going up and down |
0 to 9 | Push a digit |
$ d s r b | Drop, duplicate, swap, reverse the stack, push its size |
+ - * : % | Add, subtract, multiply, divide, modulo |
= > < | Compare, pushing 1 or 0 |
& ~ | Pop into the register; push the register |
@ # | Print a character; print a number |
, . | Read a character; read a number |
! | Pop, and skip the next cell if it was 0 |
E | End |
The commands that take two numbers take the top as their right side, so 93- pushes 6. The specification leaves some things open. The grid wraps at its edges, numbers have no bounds, : rounds down, and popping an empty stack is an error.
Example
Hello World works each code out on the stack and prints it with @.
Hello World works each code out on the stack and prints it with @. It keeps a copy of a letter when the next one is near it, so 7+ turns the e into an l.
The factorial counts down to 0 on the stack, pops the 0 with a !, and then multiplies for as long as b says more than one number is left.
The Disan count prints the even numbers below its input. Odd numbers skip the mirror that leads to the printing loop.
The program draws BEER as a glass. The pointer falls down its right side, straight through two |, and works out B, E, E and R on the way round the bottom.
Patterns it teaches
- Two-dimensional control flow: mirrors instead of arrows, and a skip as the only branch.
- Stack machines: one stack of numbers and one register.
Further
See also
Two-dimensional languages
Stack-based
Write your own in Run Convert a program from Reflecto
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: reflecto.
Command line
shib run reflecto -e ' .#E' --input '42'shib manual reflectoSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/reflecto.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org