From Esolang
Jump to: navigation, search

Letterbox is an esoteric programming language created in 2018 by Christopher Natcharian. Its structure is based on Assembly, and its interpreter is built in Python. All names of both variables and functions in the language are one letter long.


Letterbox programs manipulate a bank of 26 variables (a.k.a. registers, for those familiar with Assembly). Each is labeled as a lowercase letter from a to z and each is set to 0 by default. No other variables can be declared. Letterbox is case-sensitive, and uppercase letters are not variable names. Each variable can hold a single number, which can be an integer or a decimal, positive or negative. They can also technically hold strings (as the language is built over Python) but this implementation is buggy at best.


A Letterbox function call generally looks like Abc. A is the name of the function we are calling while b and c are two variables we are passing in as arguments. No whitespace is allowed between these characters, as spaces are what separate Letterbox statements. All Letterbox function names are singular uppercase English letters. Variables are considered "true" if their value is nonzero, and "false" if their value is zero.

Following are the four types of Letterbox function formats:

Simple Functions

A simple function follows the format Ab..., where A is the function name and b... are one or more variable arguments.

Function Name Form Description
Print (P) Pa Prints the contents of variable a.
Store (S) Sa4 Stores the value 4 in variable a. Any numerical value can be stored.
Copy (C) Cab Copies the contents of a into b.
Reset (R) Ra Resets variable a to 0. Using uppercase A as an argument resets all variables.
Negate (N) Na Boolean negation. If a is non-zero, sets it to 0. If a is 0, sets it to 1.
Copy (C) Cab Copies the contents of a into b.

Compound Functions

Since there are only 26 possible simple function names in Letterbox, some functions have been combined into one in order to save letters for other functions that might possibly be implemented in the future. These take the form AXb..., where A is the function name, X is a key letter that specifies what operation the function will perform, and b... are the variable arguments of the function.

Function Name Form Key Letters (X) Description
Math (M) MXabc A, S, M, D, E, G, L Performs a mathematical operation on b and c and stores the result in a.

Operations: add, subtract, multiply, divide, equal to, greater than, less than

Boolean (B) BXabc E, A, O, X Performs a boolean operation on b and c and stores the result in a. This result will always be 0 (false) or 1 (true).

Operations: equal to, and, or, xor (exclusive or)

Get (G) GXa I, S Pauses execution, gets input from the user of a certain type, and stores the value in a

Input Types: integer (I), string (S)


Prefix functions are functions that take in other functions as arguments. They take the general form AbF... where A is the function name, b is a variable argument, and F... is another function call, which can have its own arguments after it.

Function Name Form Description
Loop (L) LaF Repeatedly executes function F, repeating a times.
If (I) IaF If a is true (nonzero), executes function F. Otherwise, does nothing.


For ease of I/O, Letterbox has some (albeit limited) string shortcuts. A string manipulator function has the form A:string where A is the function name, and everything after the colon (:) is the string you wish to pass in.

NOTE: No spaces are allowed in strings, because whitespace is not allowed within function calls. In lieu of this, Letterbox treats underscores (_) in strings as spaces.

Function Name Form Description
Print (P) P:string Prints "string" (without the quotes). If the string contains underscores, they will be printed as spaces.
Store (S) Sa:string Saves "string" to variable a.


A valid Letterbox program is a series of function calls separated by spaces and/or line breaks. Each line of input will have its own line of output, so place your line breaks carefully.

Comments can also be placed in programs. Anything that comes after a ! character on a single line is ignored by the interpreter.

Example Programs

Hello World

! This program prints "Hello world"


This program increments a twice and prints the result.

Sa0 Sb1 Sc2
LcMAaab Pa ! This program should print out 2.

User Input

This program asks the user for their name, greets them, then asks their age, and responds differently whether the user is 20 or more years old.

P:Hi_there, Pa
GIb Sc20 MGdbc
IdP:Wow,_you're_old! Nd IdP:Well,_you're_still_young!


Letterbox Python source code: https://github.com/CNatcharian/letterbox