Slink
Jump to navigation
Jump to search
Slink is the first programming language made by User:3xcpy.
Overview
In Slink, execution takes place on a fixed-size 3-element stack (stack in the sense that instructions operate on the top element(s)).
You can put other fixed-size 3-element stacks on the current stack.
Flow control is done with conditional jumps.
Operations
Operation | Meaning |
---|---|
$n | Put the number n in the top slot of the current stack. |
?n | Jump to operation n if the top element of the current stack is 0, where n is zero-indexed. |
#n | Jump to operation n (unconditionally). Zero-indexed. |
& | Rotate the 3 stack elements as follows: ( a b c -- c a b ) |
+ | Add the top two elements of the current stack and put the result into the top slot. |
> | Move execution to the stack that is located in the top slot of the current one. |
< | Move execution to the stack that the current stack is located on. |
^ | Create a new 3-element stack in the top slot of the current one and initialize all the elements to 0. |
, | Read one character from STDIN and put its value in the top slot of the current stack |
. | Treat the top value of the current stack as an ASCII-encoded character and print it to STDOUT. |
% | Print the top value of the current stack as a number. |
Notes
- % and # are technically not required, but programming without them is a pain, which is why they were added.
- For programs that need unbounded memory, Slink is pretty similar to brainfuck in that you usually have a tape made of stacks on stacks on stacks etc (like a doubly-linked list) and you walk back and forth on it, like on the tape in brainfuck.
- I wanted to make the stacks only have 2 slots, but that would just be Brainfuck (all operators act on one value, you walk back and forth on this linked list).
- There is probably a much simpler and more elegant instruction set for such a language.
- Translations from Brainfuck should be trivial (the tape is made up of linked stacks, and you walk back and forth on it, adding and subtracting from the values).
- The language originated from wanting to experiment with fixed-size stacks (8-ish elements) and recursive ones, but to make the "recursiveness" a central part of the language, the stacks had to be as small as possible, which is how it basically turned into a Brainfuck derivative.
- Although I can imagine having multiple branching chains of stacks could be way more useful than just a simple tape.
Examples
Hello World
$72.$101.$108..$111.$32.$87.$111.$114.$108.$100.$33.
Cat
,%#0
Truth machine
,&$-48+?8$1%#6$0%
Links
Example implementation (unfinished)