LOCK
No jumps and no loops. A block runs once its keys are held and no block above it can run.
MagiMaster, 2006 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
MagiMaster made LOCK in 2006, loosely after MechaniQue. Its only flow control is locks and keys. A program is a set of code blocks, and each block names the keys it needs. The program starts holding the key main. At each step the first block whose keys are all held runs from top to bottom, and the program ends when no block can run.
Read the story
So a block that keeps its own key runs again and again. The Hello World has to remove main after printing, or it would print forever. Loops come from blocks that hand keys to each other.
The machine
There is a set of keys, an accumulator and named variables. A line is an operator and a name.
| Line | Does |
|---|---|
>key <key | Add or remove a key |
?key | Add the key if the accumulator is not 0 |
+var -var *var /var %var | Work the accumulator with a variable |
=var ^var | Store the accumulator, or load it |
:var $var | Read a whole number, or print one |
#num | Set the accumulator to a number |
&... | A comment |
Any other line is printed as it stands, with \n, \t and \\ replaced. Numbers have no bound. The specification needs that for its reduction from brainfuck, which keeps the whole tape in two numbers, one base 256 digit per cell.
Example
A countdown.
A countdown. main sets things up and hands over to loop. Each run of loop prints the number, takes one off, gives up its key and takes it back only while the accumulator is not 0.
The Fibonacci program works the same way with two keys, test and calc, and a third block, done, that waits behind them. It prints The 6th Fibonacci number is 13.
Further
Ideas it shows
See also
Also in Strange time
Write your own in Run Convert a program from LOCK
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: lock.
Command line
shib run lock -e '{main
Hello, world!
<main
}'shib manual lockSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/lock.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org