We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

SStak

From Esolang
Jump to navigation Jump to search
Not to be confused with SStack.

SStak is a stack-based programming language created by Alessandro Marpino in 2026. It is interpreted, uses reverse Polish notation, and was written as a first exercise in language design. The reference implementation is a Python interpreter, and a Visual Studio Code extension provides syntax highlighting for .SStak files.

Overview

SStak programs operate on a single stack of numbers. Bare numbers push themselves; every other token either transforms the stack or produces output. Alongside the stack there is a separate named memory, written to and read from with REM and LOAD.

Two syntactic rules are enforced:

  • All commands must be written in uppercase.
  • Tokens are separated by spaces. The exceptions are a command and its own parenthesis, which are written together, and variable names, which must be surrounded by spaces.

Indices used by the parenthesised forms count from the bottom of the stack, starting at zero.

Commands

Command Effect Example
n Push the number n 2 → [2]
+ - * / Pop two values and push the result 1 1 + → [2]
++ -- ** // Fold the whole stack with that operator, right to left 1 34 23 ++ → [58]
DUP Duplicate the top value 1 DUP → [1, 1]
DUP( i ) Push a copy of the value at index i 1 5 3 DUP( 1 ) → [1, 5, 3, 5]
REP Pop a and b, push b a times 3 5 REP → [5, 5, 5]
DEL Discard the top value 2 1 DEL → [2]
DEL( i ) Discard the value at index i 1 5 3 DEL( 1 ) → [1, 3]
DELALL Empty the stack 1 5 3 DELALL → []
PICK( i ) Move the value at index i to the top 1 5 3 PICK( 1 ) → [1, 3, 5]
REM Pop a value and store it under the preceding name 100 variable REM → [], memory {variable: 100}
LOAD Push the value stored under a name variable LOAD → [100]
SHOW Print the stack, leaving it unchanged 1 5 3 SHOW prints 1, 5, 3
^^ ... ^^ Comment, single- or multi-line 2 3 REP ** ^^ a power ^^
: ... : Print literal text. Stack[ i ] interpolates a stack value; £ emits a line break : Hello £ : : World :
:? ... ?: Print a prompt and push the number the user types :? Tell me a number ?:
( name body ) name Define a function, then call it by name ( multiply_all ** 1 ) 2 2 2 multiply_all

Examples

Hello, world!

: Hello, World! :

Fibonacci sequence

4 1 REP
^^ is ignored! ^^
DUP( 1 2 ) +
DUP( 2 3 ) +
DUP( 3 4 ) +
DUP( 4 5 ) +
DUP( 5 6 ) +
DUP( 6 7 ) +
: The Fibonacci sequence is: : SHOW

Output:

The Fibonacci sequence is: 1, 1, 2, 3, 5, 8, 13, 21, 34

Computational class

The computational class of SStak has not been established. The language has no conditional branching and no unbounded iteration: REP duplicates a value a fixed number of times rather than executing code repeatedly, so a program's control flow is fully determined before it runs.

Implementations