esolang

Doorspace

A program is a corridor of doors. Walk past the closed ones, step through the open ones, and end up somewhere else.

David.werecat, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, world!

The idea

David.werecat made Doorspace in 2012, also called Qugord. Every line of a program is a door, and the doors stand in a row. Execution visits a door, runs the code on it and moves on. A closed door leads to the next line. An open door leads wherever it was mapped, which is the next line until a map statement says otherwise. Loops are doors that lead back, and a program ends at the door -1 or past the last line.

Read the story

There are no variables. Data lives in one array of integers, a stack, and an input and an output array. The words are meant to read like plain English to people who do not program.

The machine

StatementDoes
open close switch #Change a door
map # to #Send an open door somewhere else
check #Emit 1 if the door is open
at nWrite the emitted value to index n when the part ends
shape 5Emit 5
join $ and $Emit a sum; also differ, clones, fits, produce and five bitwise ones
more less sameEmit 1 or 0
make n into $Write a value
learn $Emit an input byte, or -1 past the end
give $ to $Put a value in the output array
publishPrint the output array and empty it
pile $ grab sizeThe stack
group affect eachName a range of the array, fill it from a string, loop over it
alsoSplit a line into parts that run one after another
choose full $Run the rest of the line only if the value is not 0

A value $ is written %5 for the number 5, 5 for the value at index 5, or @5 for the value at the index that index 5 holds.

Example

Hello, world fills a group of 13 cells from a string, then copies it cell by cell to the output array.

Hello, world fills a group of 13 cells from a string, then copies it cell by cell to the output array.

The cat keeps two doors. run2 prints a byte and leads back to run1, which reads the next one. At the end of the input learn gives -1, and run1 opens itself onto the END door.

Expected: door

The truth machine prints 0 and opens the door to the END, or falls through to a loop that prints 1 forever.

Expected: 0

The specification also has a Fibonacci printer, a greeter and a Deadfish interpreter, which all run.

Patterns it teaches

Further

Object-oriented paradigm

Functional paradigm

Write your own in Run Convert a program from Doorspace

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run doorspace -e '~group hello from %2 to %14 also affect hello into "Hello, world!" also each hello into 0 task give 0 to 1 also at 1 join 1 and %1
~publish also split hello'
shib manual doorspace

Source

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

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

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