esolang

Windmill

No if and no while. The program goes round and round, and can only switch its own output off.

RainbowDash, 2024 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 11 known programs · Test method

Run it

Expected: Pan

The idea

RainbowDash made Windmill in November 2024. It is branchless; there is no if, while or for. The whole program is one loop. After the first round it starts again at the line marked with a colon, so the lines above that run once and set things up. A program decides with arithmetic instead of jumps. A comparison is 0 or 1, and multiplying by it keeps a value or drops it.

Read the story

Two variables steer the loop. While io is 0, print and prompt do nothing. When halt is 1 at the end of a round, the program stops.

The machine

LineDoes
name = expressionAssign
name[i] = expressionSet item i of a string
print expressionPrint and end the line
prompt nameRead a line, as a number if it is one
:labelWhere every round after the first starts

Expressions have numbers, names, + - * / %, < > <= >= == !=, parentheses and a[i]. A string in double quotes is an array of character codes, and parts written side by side are joined, as in print "Hello, " name "!". Names are letters only, in any case. Every other line does nothing, so plain text can sit in a program as a comment.

The reference is a JavaScript function that hands each expression to eval, and this implementation follows it. The operators mean what they mean in JavaScript, so 1 < 2 < 3 is 1. An item read past the end of a string is -1, and so is a variable that was never set.

Example

The string example.

The string example. Item 1 of Pin becomes a.

The counter. The first round sets i to 0; every round after it starts at the colon.

Expected: 1 2 3 4 5

The modulus takes 5 from 97 until it is less than 5. io is 0 until then, so only the last value is printed. halt is set in that round, but the round runs to its end first.

Expected: 2

The cat and its greeting. A line that is not a number is kept as its character codes.

Expected: cat
Expected: What is your name? Hello, Ada!

The specification also has a guessing game, a password lock and 99 bottles of beer, all of which are included.

Patterns it teaches

  • Turing completeness: the specification argues it from general blindfolded arithmetic, where a loop of assignments without a single branch is enough.

Further

Also in Strange time

Write your own in Run Convert a program from Windmill

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run windmill -e 'Prompt A
Print A
Halt = 1' --input 'cat'
shib manual windmill

Source

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

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

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