Semper dissolubilis
Functions are written down; types are never declared. Whatever no rule can rewrite is an object.
Hakerh400, 2020 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Hakerh400 made Semper dissolubilis in 2020. A program is only rules of the form left: right, and a(b, c) can mean a call of a or an object of type a with fields b and c. Which one it is depends on whether some rule matches it. Pair, null, 0 and 1 in the programs are never defined anywhere; they are types because nothing rewrites them.
The machine
| Form | Means |
|---|---|
a(b, c): d(e, f) | Rewrite a(b, c) wherever it appears into d(e, f) |
&x on the left | Match anything and call it x on the right |
a(b(&c), &d) | Match only when the first argument is a b with one field |
f | The same as f() |
The first rule in the source that matches wins. Evaluation is lazy, so an argument is only worked out when a pattern has to look inside it.
Input and output are bits, lowest bit of each byte first. Each bit b becomes 1(b(...)) and the end is 0(0(0(...))) forever. So the input a reaches main as 1(1(1(0(1(0(...)))))), and the result of main is read back the same way.
Example
The second program writes the bits of !, 0x21, lowest first.
The second program writes the bits of !, 0x21, lowest first. The third is the bit reverser. It turns the whole input around bit by bit, so bd comes out as &F.
The longest program adds two decimal numbers with nothing but Pair, null, 0 and 1. It reads the digits, builds binary numbers, adds them and divides by ten to print the sum. 12 34 gives 46 in 21,937 steps. The specification's own numbers, 179 and 195 digits long, need work nested 674 terms deep, more than the 400 this implementation allows, so that run stops after 172,477 steps.
Patterns it teaches
- String rewriting: rules rewrite terms until none applies.
- Code as data: a call and a data structure are the same thing.
- Encoding tricks: text travels as a chain of bits.
See also
Object-oriented paradigm
String-rewriting paradigm
Write your own in Run Convert a program from Semper dissolubilis
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: semper-dissolubilis.
Command line
shib run semper-dissolubilis -e 'main(&x): x' --input 'Hi!'shib manual semper-dissolubilisSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/semper-dissolubilis.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org