esolang

COSOL26

Three stacks with a type each, and a stack index that says which one a command works on.

MxBrahms, 2026 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: hello

The idea

MxBrahms wrote COSOL26 in 2026 as the successor of COSOL22, the COmmon Stack Based Programming Language. It has three global stacks, mth for 32-bit integers, str for strings and cnd for conditions. Literals go to their own stack by themselves, so #5# lands on mth, "hi" on str and TRUE on cnd.

Read the story

Commands like duplicate, swap and drop work on whichever stack the stack index points at, and | sets the index from mth. Functions have names that are strings, so a call is a string popped from str, and a program can call a function named after a line of its input. A call to a function that does not exist goes to the function named ^, if there is one.

The machine

CommandDoes
#5# "text" TRUEPush to mth, str or cnd
. _Print to "stdout"; read a line from "stdin"
, / ~ ?Drop, duplicate, swap, clear on the indexed stack
| <Set the index; move a value between stacks
#3#; [ ] ;; [ ]Loop 3 times; loop while cnd is TRUE
"f": { } ^Define a function; call one by name
( ) $( )Math on mth; text on str
` `> <-Throw; set the handler; run the next block as safe

User stacks such as <$name> are stack 3. A function has its own user stacks unless it is global. This implementation leaves out header files, #!include and every file other than stdin and stdout.

Example

The cat reads one line and prints it.

The cat reads one line and prints it.

The truth machine, without its comments. The line it reads is the name of the function it calls, 0 or 1. Anything else calls ^.

Expected: 0

A loop that counts to 3, and arithmetic. In ( ) the operators work on mth; #1#| points the index at str, and #0#< moves the top of mth there as text.

Expected: hip hip hip hooray
Expected: 42

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from COSOL26

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: cosol26.

Command line

shib run cosol26 -e '"stdin" _ $$ take input
"stdout" . $$ print it to stdout' --input 'hello, cosol'
shib manual cosol26

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/cosol26.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org