S.I.L.O.S
Superb Interpreted Language's Obviously Superior. Also known as SIL, the Simple Interpreted Language.
rjhunjhunwala · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
S.I.L.O.S is built for a nostalgic view of the past. One command per line, one letter per variable, a label on a line of its own and GOTO to reach it. There is no syntax checking at all. A line that is not a command is skipped, so plain text works as a comment.
Read the story
Each variable is a cell of one heap of 32-bit integers, named by its character. a is cell 97, and a longer name like count is just c. The same heap can be reached by number with set and get, which makes pointers and arrays possible.
The machine
| Command | Does |
|---|---|
print text, printLine text | Print the rest of the line as typed, the second with a newline |
printInt x, printChar n | Print a variable as a number, or a value as a character |
x + n and - * / % ^ & : ! ? < > | Change x in place, like x += n in C |
x = n, x = get n, x = (a + 2) * b | Assign a value, the cell at n, or an expression |
set n m | Put m in the cell at n |
lblname, GOTO name, if n name | A label, a jump, and a jump when n is above 0 |
funcname, GOSUB name, return | Functions without arguments |
stack n m, stackPop n, queue n m, queuePop n | 32 stacks and 32 queues; a pop lands in m |
readIO, loadLine | A number into i, or a line of text into cells 256 on |
The heap has 8192 cells unless the first line is a number. A second line def a b turns every a in the program into b before it runs. Expressions are worked out in floating point and cut to an integer, with ^ first and every operator read left to right, so 2^3^2 is 64. An error inside one command, such as a division by zero, skips that command and the program carries on.
On Try It Online the input comes as command line arguments. Each line of the input is one argument. The leverage command, which pulls in a standard library, is not built.
Example
The second program counts to five.
The second program counts to five. b is set to 6 minus a, and the loop goes on while it is above
- The last one reads a line into the heap and walks it with a pointer until it finds an empty cell.
Patterns it teaches
- Counter machines: integer cells, arithmetic and a conditional jump are all a program needs.
- Turing completeness: the heap has a fixed size, but the 32 queues grow without limit.
Try this
- Print the numbers 10 down to 1.
- Read a line and print it backwards.
- Hard: a function that prints the value of
nin binary.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from S.I.L.O.S
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: silos.
Command line
shib run silos -e 'print Hello, World!'shib manual silosSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/silos.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org