We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
LayerUpon
| Paradigm(s) | Imperative, stack-based |
|---|---|
| Designed by | Eason1234567890987654321 |
| Appeared in | 2026 |
| Computational class | Unknown |
| Major implementations | Python |
LayerUpon is an esoteric programming language based on a stack-oriented virtual machine. Its source code consists entirely of four types of brackets and the ASCII space character:
( ) [ ] { } < >
LayerUpon uses bracket sequences to represent instructions and binary integers. It supports integer arithmetic, character input and output, stack manipulation, labels, and conditional jumps.
The language is implemented in Python and has an accompanying graphical development environment.
Overview
LayerUpon programs operate on a stack of arbitrary-precision integers, subject to the memory limitations of the implementation.
The interpreter processes source code in two stages:
- Characters other than
()[]{}<>and ASCII spaces are removed. - The remaining characters are tokenized into instructions and executed by a stack-based virtual machine.
Line breaks are ignored during source filtering. However, ASCII spaces are significant because each space represents an input instruction.
The language has no named variables. Values are stored on the stack and manipulated using arithmetic and stack-copying instructions.
Instruction set
| Syntax | Instruction | Description |
|---|---|---|
(...)
|
PUSH | Decode the enclosed square brackets as a binary integer and push it onto the stack. |
)(
|
Pop the top value and output the corresponding Unicode character. | |
[]
|
ADD | Pop two integers and push their sum. |
][
|
SUB | Pop b, then a, and push a-b.
|
{}
|
MUL | Pop two integers and push their product. |
}{
|
DIV | Pop b, then a, and push a//b.
|
| ASCII space | INPUT | Read the next non-newline character and push its Unicode code point. |
<...>
|
PICK | Copy an existing stack element at the specified depth. |
>...<
|
LABEL | Define a numeric jump label. |
><
|
JNZ_NE | Jump if the condition is not equal to zero. |
>(...)<
|
JNZ_NE | Jump if the condition differs from the specified integer threshold. |
Binary numbers
Inside numeric instructions, the square brackets represent binary digits:
[represents 1.]represents 0.
Other characters inside a numeric field are ignored by the number parser.
Examples:
| PUSH instruction | Binary | Decimal |
|---|---|---|
()
|
Empty | 0 |
([)
|
1 | 1 |
([])
|
10 | 2 |
([[)
|
11 | 3 |
([]])
|
100 | 4 |
([][)
|
101 | 5 |
([]]]]][)
|
1000001 | 65 |
Arithmetic
Arithmetic instructions operate on the top two stack elements.
For example, the following sequence:
([][) ([[) []
performs:
PUSH 5 PUSH 3 ADD
The resulting stack contains:
[8]
Subtraction and division are order-sensitive.
Division uses Python-style floor division. In the reference interpreter, division by zero removes both operands without pushing a result.
If fewer than two operands are available, an arithmetic instruction does nothing.
Stack manipulation
The PICK instruction copies a stack element without removing the original.
The encoded number specifies the depth, starting from zero at the top of the stack.
For example, given:
[10, 20, 30]
the depths are:
| Depth | Value |
|---|---|
| 0 | 30 |
| 1 | 20 |
| 2 | 10 |
If the requested depth exceeds the current stack size, the bottom element is copied.
If the stack is empty, PICK does nothing.
Control flow
LayerUpon uses numeric labels and conditional jumps.
Labels
A label has the syntax:
>binary<
For example:
>[<
defines label 1.
Labels do not modify the stack.
The interpreter constructs a label lookup table before execution. If multiple labels share the same ID, the last definition is used.
Conditional jumps
The basic conditional jump is:
><
It removes two values from the stack:
- The condition, popped first.
- The target label ID, popped second.
If the condition is nonzero, execution continues at the specified label.
Otherwise, execution continues with the next instruction.
The stack must therefore contain the target ID below the condition immediately before the jump.
Custom threshold jumps
LayerUpon also supports a conditional jump with a constant threshold:
>(binary)<
For example:
>([[)<
uses the threshold 3.
Its behavior can be expressed as:
condition = pop()
target = pop()
if condition != 3:
jump(target)
The simplified instruction >< is equivalent to >()<, which uses threshold 0.
If the target label does not exist, execution continues with the next instruction.
If fewer than two stack values are available, the jump does nothing.
Input and output
Input
A single ASCII space represents an INPUT instruction.
The reference interpreter reads characters from standard input and pushes their Unicode code points onto the stack.
The current implementation skips carriage returns and line feeds when reading input.
For example, entering the character 4 pushes the integer 52, its Unicode code point.
Because spaces are executable instructions, formatting a LayerUpon program by inserting spaces may change its behavior.
Output
The PRINT instruction is:
)(
It removes the top integer from the stack and attempts to output the corresponding Unicode character.
For example, the integer 65 produces the character A.
Values outside the valid Unicode code-point range are displayed using an error marker by the reference interpreter.
Examples
Print Hello World
The code below will print out 'Hello World!'
([]][]]]))( ([[]][][))( ([[][[]]))( ([[][[]]))( ([[][[[[))( ([]]]]]))( ([][][[[))( ([[][[[[))( ([[[]][]))( ([[][[]]))( ([[]][]]))( ([]]]][))(
Output:
Hello World!
Print A
([]]]]][) )(
Output:
A
The first instruction pushes 65. The second instruction prints the corresponding character.
Addition
([][) ([[) []
This program calculates 5 + 3 and leaves 8 on the stack.
It does not produce visible output because it contains no PRINT instruction.
Single-digit adder
The following program reads two decimal digit characters and outputs their sum as a single digit, provided the result is between 0 and 9.
([[]]]])][ [])(
The leading space and the space between the arithmetic instructions are both INPUT instructions.
The program performs the equivalent of:
a = read_character() push(48) subtract() b = read_character() add() print_character()
Example interaction:
4 1 5
The first two lines are user input; the final line is the result.
The program subtracts 48 from the first digit's character code and then adds the second digit's character code.
It does not perform decimal formatting for sums greater than 9.
Computational class
LayerUpon supports integer arithmetic, conditional branching, labels, and stack manipulation.
One approach to investigating its computational power is to simulate a two-counter machine.
Two nonnegative counters, A and B, can be encoded as a single integer:
S = 2^A * 3^B
Incrementing either counter corresponds to multiplying S by 2 or 3.
Zero tests can be implemented by testing divisibility by the corresponding prime. Division, multiplication, and subtraction can be combined to calculate remainders.
Conditional jumps can then select the appropriate control-flow branch.
A complete proof of Turing completeness would require a correct construction for every instruction of a universal two-counter machine, including conditional decrement, branching, and halting.
The computational class of LayerUpon is therefore listed here as unknown pending a complete proof.
Implementation
The reference interpreter is written in Python 3.8+.
It consists of a source filter, tokenizer, and stack-based execution engine.
The command-line interpreter supports optional execution tracing.
Example:
python LayerUpon.py --debug f hello.layer
Debug tracing can be enabled using:
python LayerUpon.py --debug t hello.layer
The project also includes a graphical IDE developed with PySide6.
The IDE provides source editing, syntax highlighting, multiple tabs, and program execution controls.