StaPLe

StaPLe (Stack Processing Language) is a stack-based programming language created by User:BCompton in 2014 influenced by Lisp and Joy, among others.

Stacks
Almost everything in the language is stored on a pair of stacks. Stack one starts as the code stack, and stack two starts as the data (current) stack. There is also a register that can be used for storing a single token.

You can push and pop to either stack, depending on what stack is currently selected. The flip command changes the current stack. The warp command changes the code stack.

It's possible to have the data stack and the code stack pointing to the same stack. This can lead to infinite loops in many cases.

New stacks can be created with square brackets []. They can include commands inside them. You can push to and pop from created stacks using <- and ->. Subroutines can be executed by constructing a stack and then calling eval, which unwraps the new stack and pushes it onto the code stack.

Code
The code stack is initially populated by the source code, with the last commands in the code being the first to be executed.

Code execution begins by popping the code stack, then executing the command that was popped. If the item popped is not a command, it will be pushed on to the current stack.

Execution continues until there are no items left on the code stack.

Code tokens are terminated with a. Comments start with a  and go to the next. Strings start with a  and continue to the. There is no escape character.

Register
You can prepend a command with R to access the register instead of the current stack.In the case of multi - parameter commands, the FIRST value popped will be from the register. Items popped from any stack will be stored in the register - the current value in the register will be clobbered. You can store a code defined stack in the register.

Types
The supported types in StaPLe are integers, strings, booleans, commands, and stacks. Stacks can be nested. All types have truthey and falsey values.

Instructions
StaPLe has the following commands:

Boolean Operations
If a boolean operation pops a stack as a parameter, the stack will be evaluated before the condition is resolved. Be aware, this happens on the same stacks as the rest of the program, so side effects are always possible.

Hello World
drain; flip; warp; unwrap; [eval;]; [putc;]; "Hello world!; unwrap; [warp;];

This will also work, but isn't near as fun: put;"Hello world!;

Factorial
eval;dup;[eval;dup;swap;ife;swap;[pop;*;push;dup;];swap;[drain;flip;Rput;];dup;-;1;swap;];pop;dup;get;

Interpreter

 * Python 3 interpreter