esolang

Erase

Five commands, and the only memory is the program's own text.

2025 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: hello world

The idea

Erase has no variables, no tape and no stack. A command names a place in the program, either a character by its index or a line by its number, and reads it, overwrites it or erases it. Data is text the program carries, and a line that is not a command is passed over.

Read the story

So a Hello World writes its letters once, helo wrd, and prints them by position. A truth machine keeps its input as a character in its first line, and a loop is a jump back that depends on a character the program can change.

The machine

CommandDoes
erase xErase the character at x
write a xWrite the character a at x
print xPrint the character at x
if x y zGo to z if the character at x is y
goto xGo to x

A position is a character index from 0, or $n for the start of line n, also from 0. A literal is exactly one character and may be a space or a line break.

The specification leaves open what happens to the characters after an erased one. Its 100 10 1 program only works if nothing moves, so an erased character leaves an empty place that prints nothing.

Example

The truth machine prints character 7, its input.
Expected: 0

The truth machine prints character 7, its input. If that is a 1, it jumps to character 9, the start of print 7, and prints again forever.

The 100 10 1 program prints its first line, erases the last 0 of it and starts again. Line 4 prints character 3, the line break.

Expected: 100 10 1

Patterns it teaches

Further

Self-modifying

Write your own in Run Convert a program from Erase

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run erase -e 'input: 0
print 7
if 7 1 9'
shib manual erase

Source

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

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

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