A Turing-Complete Stack-Based Programming Language

The Language

Each program has access to one piece of data: a stack of unlimited size, initially empty. The stack is implicit: the program never refers directly to it. However, each operator takes its arguments from the stack and leaves its result there.

The language includes most of the usual data types, both simple (numbers, characters, booleans) and aggregate (strings, lists, sets).

A program is a list of values and operators.

Standard operators include:

Every program ends with a period.

The language also includes "quoted programs" and higher-order operators such as map. (More later.)

Some Programs

This program    2 3 + .    computes (2 + 3) and leaves a 5 on the stack.

This program    2 3 dup * + .    computes ((3 * 3) + 2) and leaves 11 on the stack.

What does the stack look like after executing each of these programs?