Qdeql

Qdeql is an esoteric programming language devised by Scott Feeney that provides a single queue of bytes as the only form of memory available to programs.

Instructions
If the queue is empty, any instruction that would normally use a value from the queue instead uses 0.

Computational capability
Qdeql is Turing-complete, as brainfuck with a fixed number of unbounded non-negative cells can be reduced to it. (See Collatz function for a proof that 3-cell brainfuck is Turing-complete.) A Haskell program is available for performing such a translation, as well as some translated examples.

Qdeql was originally thought to be unusable for computation due to the difficulty of accessing a particular byte more than once when the queue is of arbitrary size. However, Ørjan Johansen observed that the code  will skip over (dequeueing and re-enqueueing) an arbitrary length string of   triples terminated by a , with the mild inconvenience that the terminating   at the end will be deleted.

Factory
A fundamental building block in the n-cell brainfuck to Qdeql translation is the "factory" construction of the following table. It consists of two alternating patterns and a subprogram such that when the subprogram is applied with either pattern at the beginning of the queue, it is deleted while four zeros followed by the other pattern are appended to the queue.

An alternative subprogram leaves out the final  in the resulting pattern, instead absorbing it from whatever is to the pattern's right.

With our brainfuck cell representation, the zeros are used to replenish those consumed by other actions, while the absorption feature allows a quicker decrement operation.

The factory patterns/programs can conceptually be divided into three subregions:
 * The rightmost producer region (which flips between two phases on each cycle) either creates or absorbs value 255 cells, passing them on to
 * The decrementer region, which gradually decrements non-zero cells, and when they reach 2 passes them on to
 * The stretcher region, which decrements non-zero cells down to zero, while adjusting the intermediate zero cells so that a total of four zeros are passed on leftward per cycle. (Four zeros are just enough to allow us to increment a brainfuck cell in a single cycle.)

Cell layout and command translation
Once initial setup is finished, the queue consists of the patterns for the brainfuck cells, conceptually arranged in a circle.

Each brainfuck cell consists of three regions in order: its factory, its data (encoded as repetitions of ), and its zero padding. Occasionally an additional scratch region is temporarily inserted before the data region of the "current" cell.

The main part of the Qdeql program consists of a sequence of regional actions: a factory action is followed by a data action, which is followed by a padding action, which is followed by a factory action for the next cell in the queue, etc. At each point in the Qdeql program we always know the type of region being passed through, as well as the relative position of the current brainfuck cell in the queue.

With the exception of  and , which simply change which relative position in the queue is considered the "current" brainfuck cell, the translation of a brainfuck command consists of a sequence of actions to be applied to particular regions of the current brainfuck cell. This frequently requires first inserting NOP/default actions to navigate to the current cell and the correct region, and then inserting the substantial action.

The NOP/default actions work as follows:
 * The data action moves the data section to the end of the queue, except that the final zero is deleted.
 * The padding action deletes the  padding.
 * The factory action replenishes the four zeros deleted by the previous actions, and moves the factory section to the end of the queue.

Sometimes several consecutive brainfuck commands can be translated without navigating the queue between them. E.g. the actions generated by  all act on consecutive regions in the queue.

The I/O commands are more complicated than the others, as they need to convert between unary representation and bytes (using a temporary scratch region), and so these take more than one regional action to translate. This is done in order of row, then column/region.

Initial setup
The following table shows how to build n brainfuck zero cells from a  + 7n times   pattern. Cells are built "in parallel", sharing the main loop of the first one.

After this initial setup the queue will be correctly positioned for a data action.

Example structure
The following table shows, top to bottom, left to right, the structure of the Qdeql program translating the brainfuck program  (which prints a space). Non-default parts of commands are marked.

External resources

 * Qdeql implementation and source code