Mascarpone
The interpreter running your program is a value on the stack. Take it, change what a symbol means, and put it back.
Chris Pressey, 2007 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 5 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Chris Pressey designed Mascarpone in 2007 as a successor to Emmental. In most languages the meaning of each symbol is fixed. In Mascarpone the meaning lives in an interpreter, a map from symbols to operations. v pushes the interpreter that is running right now onto the stack, < makes a copy in which one symbol does something else, and ^ installs that copy. From then on the program is read by the new interpreter.
Read the story
An operation is a string of symbols together with the interpreter that gives them meaning. Every interpreter also has a parent, and that chain of parents works as a second stack. There are no loops; an operation that installs itself under a symbol and then runs that symbol is how a program repeats.
The machine
The stack holds symbols, operations and interpreters. A string is a run of symbols between [ and ].
| Symbol | Does |
|---|---|
v ^ | Push the current interpreter; pop one and make it current |
< > | Bind a symbol to an operation in an interpreter; look one up |
{ } | Get or set an interpreter's parent |
* | Pop an interpreter and a string; push the operation they make |
@ ! | Take an operation apart into string and interpreter; run it |
0 1 | The null interpreter; an interpreter giving every symbol one operation |
[...] 'x | Push a string; push one symbol |
. , | Print a symbol; read one |
: $ / | Duplicate, drop, swap |
Any other symbol does nothing in the initial interpreter. The stack is a plain stack, so a string pushed as [ab] comes off as ], b, a, [.
Example
The second is the truth machine from esolangs.org.
The second is the truth machine from esolangs.org. It builds an interpreter in which every symbol prints 0, except 1, which prints 1 and runs itself again. Then it runs the input with that interpreter. Given 1, it prints 1 forever.
Further
Ideas it shows
See also
Stack-based
Write your own in Run Convert a program from Mascarpone
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: mascarpone.
Command line
shib run mascarpone -e ''\''a'\''b/..'shib manual mascarponeSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/mascarpone.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org