Betaload

Betaload is an esoteric programming language created by user:Challenger5. It is a derivative of Underload.

Betaload adds the concept of environments: An environment is a space where commands can be executed. Each environment has two stacks: the standard Underload stack of strings, and a stack of sub-environments.

Each Betaload environment can be in one of two possible modes: S-mode or E-mode. These affect whether certain commands act on the string stack or the environment stack. It is recommended that code should generally stay in S-mode; all code on E-mode should be enclosed between  (the command to toggle modes) and should avoid using instructions that only affect the string stack.

Betaload was designed to make Underload more usable by providing a mechanism for input as well as for a form of object-orientation (or at least grouping of related functionality). It is backwards compatible with Underload (provided that no invalid commands are used).

Complex Commands
The command, when executed in E-mode, will pop an environment from the stack and push onto the string stack the code necessary to create that environment. For example,  will push   onto the string stack. It essentially un-evals the environment, just like executing  on a string unevals that string. This allows for environments to be manipulated like strings on the string stack. For example,  will rotate the top three environments on the environment stack.

The command, when executed, will create a dictionary mapping characters to strings. While the top value on the stack is a single character, it will pop that character, pop another string from the stack, and add them to the dictionary. Then, it will read input from STDIN. Every character in the string read will be replaced with its corresponding value in the dictionary (unless the value is not in the dictionary, in which case it will be ignored.) This new string will be pushed to the stack.

Examples
Cat Program (only functions with digits 0-9):

(a(:^)*(This string is here to act as a stopping point for R. It will be removed by R. )( )!(0):!(1):!(2):!(3):!(4):!(5):!(6):!(7):!(8):!(9):!RS):^

It infinitely reads a string of digits and replaces them with the code to print that digit, and then executes the resulting string. Note that it has not been tested and might not work.

Implementations
An implementation can be found on github. Note that it has some weird quirks like treating  and   separately (so you can have things like  ), but it supports all the specified behavior correctly.