Transceternal
The program, its instruction pointer and its input all live in one graph, and running it rewrites that graph.
Hakerh400, 2019 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Hakerh400 made Transceternal in 2019 as a close relative of his language Realm. Realm keeps its source and its instruction pointer outside its memory. Transceternal keeps everything in the graph. Every node has a 0-pointer and a 1-pointer, and an address is a string of bits that walks from the root.
Read the story
Any text is a program. Each character is a token, or each word when the text has whitespace. The tokens are laid out depth first, a new token making a new node and a repeated one pointing back at the node it made. Then a new root gets that graph on its 0-pointer and the input on its 1-pointer, as a chain with one node per bit, lowest bit first.
The machine
The node at 000 stands for bit 0 and the node at 001 for bit 1. An address is read from a chain of nodes, a 0 where a node's 0-pointer is the node at 000 and a 1 otherwise. The node at 01 is the current instruction. In the table, an address in brackets means the address read from the chain found there.
When the node at 0100 is | Does |
|---|---|
The node at 000 | [01010] gets the node at [01011], then 01 gets 011 |
The node at 001 | [01010] gets a new node pointing at [010110] and [010111], then 01 gets 011 |
| Any other node | 01 gets 01011 if [010100] and [010101] hold the same node, else 011 |
The run stops when the node at 01 is the node at 000. The output is the chain at 1, read as bits, eight to a byte.
Example
In the cat the node at 01 is already the node at 000, so the program stops before its first step.
In the cat the node at 01 is already the node at 000, so the program stops before its first step. The input chain is then read with the nodes it was built with, and comes out as it went in. The empty program has one node for both bits, so every input byte comes out as 0.
The digit program takes one step. It points the output at the node at 001, which heads a chain that reads 110011, the bits of 51, the code of 3.
The Hello, World! program is written in words, so each pair of hex digits is one token.
Patterns it teaches
- Code as data: the program, the instruction pointer and the input are nodes of the same graph.
- Every text runs: any string is a program, even the empty one.
- Self-modifying code: each step rewrites the graph the program is made of.
Further
See also
Also in Rewriting
Write your own in Run Convert a program from Transceternal
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: transceternal.
Command line
shib run transceternal -e 'catacat' --input 'Hello, World!'shib manual transceternalSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/transceternal.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org