"*><> (Starfish)"
><> with functions, a way to swim past code without running it, and a fisherman who pulls the fish down a line and back.
redstarcoder, 2016 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
redstarcoder made *><> in 2016 to make ><> more useful while keeping its spirit. Every ><> program still runs. On top come call and return, a dive mode that skips everything but the arrows and mirrors, a backtick that bends the path down and back up, stack selection, file input and output and a clock.
Read the story
The reference is go-starfish, written by the author in Go. It is also what Try It Online runs.
The machine
The ><> machine: a codebox that wraps at its edges, an IP starting top left and moving right, a stack of stacks with a register each. These are the additions.
| Char | Does |
|---|---|
C | Pop y and x, jump there, and keep the old position on a new stack below the current one |
R | Jump back to the position on the stack below, and drop that stack |
u O | Dive and rise. While diving only the arrows, the mirrors, the fisherman, x and O run |
` | The fisherman. Moving sideways it turns down, the next time up; moving vertically it turns back to the last sideways direction | |
I D | Select the stack above or below the current one |
F | Open, read and write a file |
h m s S | Push the hour, minute or second; sleep for 100 ms times a popped number |
In this implementation F fails, the clock always reads 0 and S does not sleep, so every run repeats.
Example
The Hello World from Try It Online.
The Hello World from Try It Online. u dives as long as the stack has values, so ! and | are swum past on the way out and the | bounces the IP back to O.
A function call. C10 calls the code at (0,1); the second line pushes the string, the third prints it until the stack is empty and then R returns to the ; beside the call.
The fisherman prints Hi and still ends on the first line, with two backticks instead of four arrows.
Patterns it teaches
- Two-dimensional control flow: calls and the fisherman let a program leave a line and come back to the same place.
- Stack machines: a call saves its return address as a stack of its own.
Further
- esolangs.org/wiki/Starfish
- go-starfish, the reference interpreter
- Related: ><>
See also
Self-modifying
Two-dimensional languages
Write your own in Run Convert a program from "*><> (Starfish)"
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: starfish.
Command line
shib run starfish -e '94,n;'shib manual starfishSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/starfish.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org