StackLang is a stack-based programming language with simple evaluation rules. StackLang is statically typed, meaning that commands and functions check the number and type of inputs before being evaluated. The language is also turing complete, since it supports function application and abstract functions. The interpreter is currently implemented in C++.
In these files, text is sometimes formatted like this
. The altered formatting indicates that
the text is either interactions with the interpreter or not normal prose in some way. When discussing
interactions with the interpreter, both inputs and outputs are given as how they would appear when printed.
Booleans are written as true
or false
, commands <like-this>
,
numbers 12/34
, strings "like this"
, substacks << "with content here", "and maybe more content" >>
,
the special empty substack << (empty) >>
, and types Type
. Additionally,
some text is formatted like this. The formatting indicates that the text is supposed to be
a raw keystroke, combination of keystrokes, or raw input to the interpreter.
Throughout this documentation, certain terms have special meanings. These are documented below.
When discussing a command, a signature will often be mentioned. Signatures are formatted as a function name,
a colon, then a list of space-separated input types, followed by a ->
, followed by another
list of space-separated output types. For example:
add : Number Number -> Number
is
the signature for the command add
. The left hand side is the side closer to the active end
of the stack. The side closer to the active end is also the side from which paramters are numbered. The
first paramter would be the number closest to the active end, and so on. Occasionally, commands will
be missing either an input, and output, or have multiple outputs. Example:
define : Substack(Type) Substack Command ->
is
the signature for define
. Functions and commands will always pop their parameters off of
the stack, so foo? : Any -> Any Boolean
will still pop one element off of the stack, before
pushing it back on, then pushing back on a Boolean as well. Finally, Substacks, numbers, and commands
can have additional information attached to them. For example, a Substack(Number)
is a substack
that may only contain numbers. More detail on type specializations is given in the types
section.