esolang

Eval

Two stacks and no loop. A string that runs a copy of itself is the only way to repeat.

PythonshellDebugwindow, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, World!

The idea

PythonshellDebugwindow made Eval in 2020. It has two stacks, left and right, that hold strings and integers. There is no loop, and ? can only skip the one instruction after it. The way to repeat is !, which pops a string and runs it as Eval code on the same stacks. A string that leaves a copy of itself on the stack and then runs it goes on for ever.

Read the story

The only number it can write is 0. Every other number is counted from it with + and -.

The machine

CommandDoes
~Switch between the left and the right stack
` | Push 1 if the current stack is the left one, else 0
^Duplicate the top
0Push 0
+ -Add or subtract 1
*Reverse the current stack
?Pop; skip the next instruction if it was 0 or the empty string
!Pop a string and run it as code
"text"Push a string; a ` inside stands for "
'text"Push the string with double quotes around it
. ;Pop and print; pop
=Move the top to the other stack

The specification leaves a few things open. In this implementation . prints without a line break, other characters do nothing, and Eval reads no input.

Example

The truth machine has its input written into it, as Eval cannot read.

The truth machine has its input written into it, as Eval cannot read. The string 0+.^! prints 1 and runs a copy of itself. With a 0 before the ?, the ! that would start it is skipped and the program prints 0. With 0+ there instead, it prints 1 for ever.

Expected: 0

= moves a to the right stack, b is printed from the left, and ~ turns to the right to print a.

Expected: ba

' quotes code. The first ! runs "0+++.", which pushes the string 0+++., and the second runs that.

Expected: 3

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Eval

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run eval -e '"0+.^!"^0?!0.'
shib manual eval

Source

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

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

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