Indent is an esolang by User:PythonshellDebugwindow.
There is no input, and the only thing output by a program is the
main function's final return value (or 0).
main function is called with the passed Command Line Args as an IntArray.
All functions return Ints (default return value/value returned if non-Int is attempted to be returned is 0), but this could be used with Array indexing to access elements of an Array of any type. The last evaluated statement in a function is its return value. All arguments to a function must also be Ints, but they could also be used with Array indexing. The passed arguments (number of args >= 1, no args -> args = ) is stored in an IntArray called
arg. To define a nop function (no body, returns 0):
A bitwise AND function:
bwAnd arg.0 & arg.1
A (non-bitwise) not function using a conditional:
not arg.0 = !(arg.0), !(arg.0)
To call a function:
f = arg
f = [arg1, arg2, arg3]
f1 = (f2 = args)
noArgs = 0
Any non-passed args/non-Int args will be replaced with 0, and any extra args are ignored.
- This section uses Int literals in its examples for demonstrational purposes. There are no Int literals in Indent.
Variables are strongly typed. The type of their initial value will be their type for the rest of the program. To initialize the variable
myVar to Int and set it to 123:
To change it:
But you can't assign it a different type, as any attempts to do so will fail silently:
main myVar <123> myVar <1, 2, 3> myVar
123, as assigning a value of type IntArray to a variable declared as an Int will fail and return
Variables declared at the top of the program can be used in all functions; variables declared in a specific function can be used only in that function; variables declared between functions are invalid and are ignored.
Datatypes are Int, IntArray, Function, FunctionArray, NDIntArray, and NDFunctionArray. The term Array can be used to generically refer to any Array type, and the term Any can be used to generically refer to any type. Ints are signed.
There are no Int literals; you can use the Command Line Args to use Ints in your program, e.g.
arg.0 & !arg.0 is always the Int 0, and using the not function described, you can turn it into the Int 1; nop functions always return 0 as well.
Truth-machine (prints nothing for input 1, but loops infinitely), treats all nonzero inputs as 1:
main arg.0 & arg.0 = main(arg.0), arg.0
XOR function (args: two Ints to XOR):
xor (arg.0 | arg.1) & !(arg.0 & arg.1)
While function (args: the Nth function in the
condfuncs FunctionArray and the Nth function in the
bodyfuncs FunctionArray) that returns 0:
condfuncs <list, of, functions> bodyfuncs <list, of, functions> while (condfuncs.(arg.0) = 0) = [bodyfuncs.(arg.1), while = [arg.0, arg.1]]
If function (args: an Int for the condition and the Nth function in the
bodyfuncs <list, of, functions> if arg.0 = (bodyfuncs.(arg.1) = (arg.0 & !arg.0))
Nop function w/ no body (this example will print 0):
nop main nop
- Undefined identifiers are treated as 0, and undefined array indexes are treated as 0 for IntArrays, nop functions for FunctionArrays, and the empty array of appropriate type for multidimensional arrays
- Regex for identifiers: