Stackowey
Paradigm(s) | Imperative |
---|---|
Designed by | User:Lampe2020 |
Appeared in | 2025 |
Type system | Static, only unsigned integers |
Memory system | Stack-based |
Dimensions | |
Computational class | Turing-complete (assumed so by the author, not yet proven) |
Reference implementation | in C++, in JavaScript |
Influenced by | Brainfuck, Befunge |
File extension(s) | .swy |
Stackowey ["stäck-o-wee"] is the serious and actually functional[1] spiritual successor of arrowey, created by User:Lampe2020. It operates on a 2-dimensional grid of characters, called the "playfield", with each character having a complete meaning in and of itself.
The source code of a Stackowey program is specified to be stored in a file with the .swy
extension (which is case-insensitive but recommended to be lowercase), although this is not enforced in the official interpreter.
Syntax
ASCII character | Name | Description |
---|---|---|
/ |
"bounce" | Pops two values off the stack. Bounces the pointer off if the first one is greater than the second one |
\ |
"backbounce" | Pops two values off the stack. Bounces the pointer off if the first one is lower than the second one |
? |
"huh" | Gets UTF-8-encoded input from the user. Pushes each character to the stack as its Unicode code point, followed by a 0 up top. Note: when the input stream has ended or otherwise failed, this command immediately halts the program with an appropriate error message |
! |
"hah" | Pops and outputs the UTF-8-encoded character according to its Unicode code point found on the stack Note: |
% |
"splot" | Pops and takes the top two stack values as coordinates to jump to while not changing direction. Note: the movement is done after the jump, so the command being jumped to is ignored! |
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 |
"oh", "itch", "nigh", "chan", "fire", "lamp", "glorp", "wa-ding" | Pushes the corresponding number to the stack |
+ |
"cross" | Pops two stack values and pushes their sum onto the stack |
_ |
"stumble" | Inverts all bits of the top stack element |
# |
"grille" | Pops one value off the stack, calls it n and swaps the n:th and topmost stack element |
@ |
"whirlpool" | Pops one value off the stack, calls it n and pushes a copy of the n:th stack element to the top of the stack |
. |
"prick" | Pops a value off the stack and throws it into the void |
8 |
"dubring" | Pushes the current coordinates to the stack |
9 |
"tailring" | Halts the program |
all other bytes | "impostor" | These are all no-ops |
The playfield must be rectangular (all lines must have the same length), with the exception of the shebang line, which is included as a convenience feature, so a Stackowey source code file can be marked executable in a *NIX environment and run directly, without needing to explicitly call the interpreter (Note that, due to the shebang line being ignored, no program can immediately begin with #!
, although that can be circumvented by inserting at least one other instruction like an impostor before or in between the #!
).
When fetching the source code from stdin, another exception is made, that being the line ---
(which separates the source code from its inputs) and all lines after it (which are the inputs).
Also, a single newline character appended to the end of the source code will be ignored.
Runtime behaviour
The program starts out with running the top left command of the playfield, then proceeds to the right. The playfield is effectively infinitely tiled, by looping teleport coordinates around and making the program loop around to the same row's (or column's, if moving vertically instead of horizontally) other end if it tries to run off the edge.
The Stack
The Stack (which Stackowey is named after, so it's capitalized because of its importance) always starts out with a single 428 (or 3410) on it.
It is a single tower of unsigned integers of all the same width, as unsigned integers are the only data type Stackowey understands. There is no restriction on the width of the Stack, as long as all Stack elements have the same (constant, so not changing during execution!) width.
Turing-completeness
Stackowey is designed to be Turing-complete, which the author thinks he succeeded with, although you would need a theoretical implementation with an infinitely wide stack that could grow infinitely tall and survive the heat death of the universe to achieve true Turing-completeness.
Examples
Note that most examples here include the shebang line, which is simply ignored by the interpreter.
Hello World
With code comments
Note: The code is also folded a bit and formatted in a way to make it a little easier to understand. The end result is the same as the minimal example below this one though.
#!/usr/bin/env -S ./stackowey -d Output the string "Hello World" by calculating its unicode values: 777777777772++++++++++ (push fourty-eight to stack)1221\ /2112 Move all the way to the left again to make the code a little easier to understand / \0@ (duplicate the top stack value) ! (output the top stack value, thereby consuming it) 77771+++++0@! ("e") 1221\ /2112 / \7+0@0@!! ("ll") 3+0@! ("o") 77774++++! (" " not based on "o") 0@71++! ("w" and discard it from stack) 0@! ("o") 1221\ /2112 / \ 3+0@! ("r") Now we need to subtract, so let's do that: 5_+ (inverted(b minus one) plus a equals a minus b) 1221\ /2112 / \ 0@! ("l") 7_+! ("d" and discarded from stack) 7775++++! (exclamation point and discard it from stack) 1221\ /2112 / \ 73+! (newline) 9 (halt)
Minimal
(Same method as the commented version above, but all on one line with no comments or shebang line)
77777777772++++++++++0@!77771+++++0@!7+0@0@!!3+0@!77774++++!0@71++!0@!3+0@!5_+0@!7_+!0_+!73+!9
Truth Machine
This is quite a lazy one, as it simply outputs 0
whenever zero or anything with a lower Unicode code point is last entered into it by the user and infinitely many 1
s in all other cases.
#!/usr/bin/env -S ./stackowey -d ?0@7777776++++++++1@1@\!73+!9 0 @ 8 1 # 1 _ + 1 + 3 @ 1 + ! %
Arithmetic operations
Examples in this section use a
and b
as placeholders for the actual numbers to be worked with, in reality those should be pushed onto the stack in the shown order before running the given snippet.
Note: some of the arithmetic operations lack examples because they are too tedious to implement when the only debugging technique available is the dev log from the interpreter along with following along in the head or executing it by hand, so once the online IDE[2] becomes usable they will be created and added.
Addition
The only built-in arithmetic operation.
ab+
Subtraction
This needs to be implemented using "cross" and "stumble":
ab_1++
This example leaves the result of a-b
on the stack.
Multiplication
This needs to be implemented as e.g. an addition loop.
Division
This needs to be implemented as e.g. a subtraction loop (which gives you the remainder for free as it actually remains).
Interpreters
- The official interpreter's C++ source code is available under the GNU GPLv3 license on Lampe2020's GitHub.
- An official online IDE is also in the works.