esolang

Eniuq

Output goes back into the program. Only a character that is no command ever reaches the screen.

Edward Cree, 2012 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: 'Sup, Earth

The idea

Edward Cree made Eniuq in 2012, and its name is quine spelled backwards. The output commands o and O do not print. They append characters to the end of the program, which is a queue, and those characters run in their turn. A character that is no operator is printed when it runs and does nothing else.

Read the story

So a program without operators prints itself, and any text like 'Sup, Earth is a quine. A program with operators never is. No program can print Hello World either, since o and d are operators and so never reach the screen.

Loops work the way quines do. The program keeps its own code on the stack and writes a copy into the queue to run again. The `O`5`D`5`A5D5O pushes the five characters of A5D5O, copies them with 5D and appends one copy with 5O. That copy prints A and appends itself again, forever.

The machine

CommandDoes
0 to 9Push a digit
+ - * /Arithmetic on 32-bit unsigned values; 31- is 2
!0 becomes 0xffffffff, anything else 0
?Read a number
~Reverse the whole stack
d kDuplicate or drop the top value
D f KPop N, then duplicate N values, copy the Nth, or drop N
o OAppend one value, or pop N and append N values, to the queue

&, | and ^ are bitwise, and everything else is printed. The preprocessor epp turns `x into code that pushes the character x, and "text" into the same for each character, last first, so that O appends the text in reading order. The stack holds 256 values and the queue 1,024 characters, and going past either is an error.

Example

The first has no operators and prints itself.
Expected: Hi
Expected: H

The first has no operators and prints itself. The second pushes i and then H, and 2O appends both to the queue, H first, where they print. The third works out 8 times 9, which is 72, and appends it as the character H.

Patterns it teaches

  • Self-modifying code: the only way to loop is to write code into the queue.
  • Quine: every program without operators is one, and no other program is.
  • Stack machines: 256 unsigned values next to the queue.
  • Code as data: the code that runs next is built on the stack.

Further

Queue-based

Stack-based

Write your own in Run Convert a program from Eniuq

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: eniuq.

Command line

shib run eniuq -e '89*7+'
shib manual eniuq

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/eniuq.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org