Logical
A language that does not do what you think it should. Every name is a lie, and every error succeeds.
David.werecat, 2012 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
David.werecat made Logical in 2012. Every line is a comment until you mark it as a comment with COMET. GOTO assigns, SET adds, MUL subtracts, DEFN prints and DIV exits. The source must be all upper case, but it is read in lower case. A ~ gives the interpreter a nervous breakdown, and any error stops the run with the message ERROR: THE OPERATION COMPLETED SUCCESSFULY.
Read the story
Values are just as twisted. The integer 123 is written "-123". A string is written backwards with _ for spaces. A variable is renamed the moment it is defined, to ROT13 of the variable defined before it, so the first one is always called YBTVPNY. The first value you give a variable is thrown away; it only sets the variable's type, to the opposite of its own.
The machine
| Statement | Does |
|---|---|
GOTO v x | v = x |
SET MUL UNDF DOIF v x y | v = x + y, x - y, x * y, x / y |
SUB n | Define a variable |
ADD n | Define a label |
DEFN x | Write x |
EXIT v | Read a character into v |
LABL x c y | Run the next statement only if x c y is false |
INPT -n OPEN -n | Jump to label n; call it |
CONV | Return from a call |
FUNC v x | v = the character with code x |
WRIT n | Undefine a variable |
DIV | Exit |
ERROR | Nothing |
A label is named by its number typed with shift held, so 123 is !@#, and it is called as -123. A jump lands three lines before the label. OUTP, RETN, CLOS and READ open, read, write and close files, which live only for the run. The comparisons are ==, !=, <=, >=, << and >>.
Example
Hello World.
Hello World. Backwards it says HELLO,_WORLD!, and the lower case reading prints it small.
SUB X makes a variable called YBTVPNY. Giving it the string a makes it an integer, and UNDF multiplies 6 by 7.
The cat jumps with INPT -123 to three lines above ADD !@#, which is its EXIT. Reading past the end of the input is an error, so the cat ends with the message.
The Fibonacci program prints 1, 1, 2 and on to 832,040, each followed by , .
Patterns it teaches
- Hostile design: names that mean something else, and errors that report success.
Further
See also
Also in Jokes
Write your own in Run Convert a program from Logical
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: logical.
Command line
shib run logical -e 'COMET DEFN !DLROW_,OLLEH'shib manual logicalSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/logical.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org