Deadfish 3
Deadfish 2's string becomes a clipboard of code. Paste it, and it runs.
A · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
A made Deadfish 3 as a superset of Deadfish 2. The string that Deadfish 2 could only read and print is now a clipboard. "..." puts text in it, and @ pastes it after itself, so the text runs next as a program of its own. Together with :, which runs the next command only when the accumulator is 0, that gives it loops and recursion, which Deadfish 2 does not have.
Read the story
h changes meaning too. It halts the innermost pasted program, and halts the whole run only outside one.
The machine
| Char | Does |
|---|---|
i d | Add 1, subtract 1 |
s | Square |
n | Set to 0 |
o | Print the number |
c | Print the number as a character |
"text" | Put the text in the clipboard |
r | Read a line of input into the clipboard |
O | Print the clipboard |
@ | Paste the clipboard after this command, so it runs next |
: | Run the next command only if the accumulator is 0 |
h | Halt the innermost pasted program, or everything |
The truth machine needs d to take 0 to -1, so the old Deadfish rule that turns -1 and 256 into 0 does not hold.
Example
The Hello world and the cat are the same as in Deadfish 2.
The Hello world and the cat are the same as in Deadfish 2.
The truth machine takes its input as code. No input stands for 0, and a single i for 1. After d r@ the accumulator is -1, or 0 when the input was i. Then :@ pastes iod@ only on 0, and that prints 1, steps back to 0 and pastes itself again, for ever. Otherwise no prints 0. It runs without the prompt, on no input.
A pasted h stops only the paste. ih adds one and halts, and the outer o still prints.
Patterns it teaches
- Code as data: the clipboard holds text that
@turns into commands. - Self-modifying code: a paste adds code to the running program.
Further
- esolangs.org/wiki/Deadfish_3
- Deadfish 2, the language it extends.
See also
Also in Jokes
Write your own in Run Convert a program from Deadfish 3
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: deadfish-3.
Command line
shib run deadfish-3 -e 'rOh' --input 'Hello, World!'shib manual deadfish-3Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/deadfish-3.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org