esolang

Printscript 5

Printscript gets comments, input, logic and if, one version at a time, and still no loop.

A, 2019 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: The previous 2 lines are skipped.

The idea

The esolangs.org user A kept adding to Printscript in 2019. Versions 5 to 8 each have their own C interpreter. Version 5 adds comments, version 6 reads input, version 7 adds and, or and not, and version 8 adds if. There is still no loop, so a program runs through once. This implementation runs version 8.

Read the story

Variables still hold one character. The logic works on characters less 48, so 0 is false and 1 is true, and the result goes back into the first variable as 0 or 1.

The machine

CommandDoes
print "text" print xPrint a string or a variable
set x c sev x ySet x to the character c, or to the value of y
- -[ ... ]A comment to the end of the line, or up to ]
input xRead one character into x
and x y or x y not xLogic on 0 and 1, kept in x
if x ... endRun the block when x is above the character 0
else x ... endRun the block when x is the character 0

else is not tied to an if. It is a second test of its own, which is why the specification writes the variable again. As in Printscript, print skips exactly one character after its name, whatever it is.

Example

The conditional prints the input when it is 1 and a message when it is 0.
Expected: 1

The conditional prints the input when it is 1 and a message when it is 0.

Expected: a is not 1!

Patterns it teaches

  • Hostile design: else repeats its own test, and print still eats a character.

Further

Also in Jokes

Write your own in Run Convert a program from Printscript 5

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: printscript-5.

Command line

shib run printscript-5 -e 'input a
print a' --input '3'
shib manual printscript-5

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/printscript-5.js

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

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