Deviating Percolator
Every capital letter in the program is the name of a register, and it reads as whatever that register holds.
AJF, 2010 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
AJF made Deviating Percolator, or DevPerc, in 2010. It has 26 registers named A to Z, and each starts as the code of its own letter. Before a line runs, every capital letter in it is replaced by the character its register holds. While the registers are untouched, PUT A reads as PUT A. Set F to 65 and the command FOO reads as AOO.
Read the story
Commands and numbers are made of the same capitals, so storing data anywhere can change what later lines say. Numbers are written as British words, such as SIXTYFIVE or TWOHUNDREDANDFIFTYFIVE. The storage is 26 bytes, so the language is not Turing complete.
The machine
| Command | Does |
|---|---|
PUT X | Write the byte X |
GET X | Read a byte into the register X names, 255 at the end of input |
DEFINE X TO Y | Set the register X names to Y |
IF X PROCEEDTO Y | Go to line Y, counted from 0, when X is not 0 |
/ | Comment to the end of the line |
An expression is one word or three. A word is a register letter, a number name or RANDOM, and two words can be joined by EQUALS, GREATERTHAN, LESSTHAN, PLUS, MINUS, TIMES, DIVIDE or MODULO. Results wrap to 0 to 255. A value names a register when it is the code of a capital letter. RANDOM follows the Munroe algorithm the specification prefers and is always 4.
Letters are replaced in comments too. A register that holds 47 turns its letter into a /, and one that holds 10 into a line break.
Example
Z becomes / and Y a line feed, so the third line reads as PUT A/VVV and then PUT B.
Z becomes / and Y a line feed, so the third line reads as PUT A/VVV and then PUT B.
After GET A, the letter A reads as the byte that came in, so PUT A no longer says what it means. The cat goes around that. M holds 65 and reads as A, Z holds 77 and reads as M, so GET Z fills A and PUT M prints it.
The countdown keeps its counter in B, but the code of its loop never names B. Q holds 66, so every Q in lines 13 to 16 reads as B, and SIXTYSIX names B.
Patterns it teaches
- Self-modifying code: data written to a register rewrites every line that mentions its letter.
- Hostile design: the names of the storage are also the letters of the commands.
See also
Also in Hostile
Write your own in Run Convert a program from Deviating Percolator
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: deviating-percolator.
Command line
shib run deviating-percolator -e 'DEFINE Z TO FORTYSEVEN
DEFINE Y TO TEN
PUT AZVVVYPUT B'shib manual deviating-percolatorSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/deviating-percolator.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org