Phile
Every variable is a file. Open it, write to it, read its line, and close it before you leave.
PythonshellDebugwindow, 2020 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
PythonshellDebugwindow made Phile in 2020. The name plays on "phile" and "file". There are no variables, only files. A program opens a file, writes to it or overwrites it, and reads a line back. The console is three more files, stdin.stream, stdout.stream and stderr.stream. Even printing Hello World means opening standard output and closing it again, since a file left open at the end is an error.
Read the story
The only control flow is a jump to a line number when a value is true. The specification argues that files of any length, as many as you like, make it Turing complete.
The machine
| Line | Does |
|---|---|
OPEN f; | Make f a current file, creating it if needed |
WRITE f v; | Add v to the end of f |
OVERWRITE f v; | Replace what f holds with v |
CLOSE f; | f is no longer current |
v? n; | Jump to line n, counted from 0, unless v is "", "0" or 0 |
READ f gives a line of f. Values are strings and integers of any size, with + - * / and the comparisons = ! < >. The specification lists the operators from the highest precedence down as */+-=![], with [ and ] for < and >. Each gets its own level, so 10 - 2 + 3 is 5. 0 + text turns text into a number and "" + n turns a number into text.
READ gives a file's first line every time, which the 99 bottles needs, and the next line of stdin.stream without its line feed.
Example
The truth machine reads a line and compares it with 0.
The truth machine reads a line and compares it with 0. On 0 it jumps to line 5, prints 0 and closes both streams. On 1 it falls through to line 3, and line 4 jumps back to it for ever.
The 99 bottles keeps the count in numberOfBottles.dat and takes one down with OVERWRITE "numberOfBottles.dat" READ "numberOfBottles.dat" - 1;. It sings all 99 verses. The cat never ends, as its last line always jumps back.
Patterns it teaches
- Turing completeness: unbounded files as variables and one conditional jump.
Further
See also
Also in Jokes
Write your own in Run Convert a program from Phile
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: phile.
Command line
shib run phile -e 'OPEN "stdout.stream";
WRITE "stdout.stream" "Hello, World!";
CLOSE "stdout.stream";'shib manual phileSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/phile.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org