Luminol
Paradigm(s) | Functional |
---|---|
Designed by | User:Zaikawo |
Appeared in | 2024 |
Computational class | Turing Complete |
Reference implementation | Implemented |
File extension(s) | .lum |
Luminol[1] is an esoteric programming language.
Values
Luminol data is stored in values; lists of bytes externally treated like unbound signed integers.
Values lack a type, as they can be treated as any type formed of bytes. This gives them a lot of flexibility and usability, as they can be used to directly convert from one datatype to another.
Transformations
Data in Luminol doesn't natively come as values, but as either Strings, Ints or Booleans. (yes, this language doesn't support decimals. cry about it.)[2] Transformations are automatically applied by the interpreter when evaluating outside values.
- Strings are converted into values such as that every byte contains the ascii code of the letter at that spot. For example,
Hi
would turn into a value containing72, 105
. - Integers are converted into BigInts, utilizing base 256 at each node (each byte) of the list.
- Booleans are converted into a single byte containing
1
if true, or0
if false.
Signs
All values start out as positive, although they can be changed via operations such as the -
negation operation, or by subtracting a bigger value, etc.
Negative values printed as strings are printed in reverse.
Signs do not affect truthyness.
Truthyness
Speaking of truthyness, the truthyness of a value is simply determined by if it equals the false
boolean representation. If it does, it's false. If it doesn't, it's true. This means that any text that is not empty, and any number below or above zero is true.
Syntax
Syntax for Luminol follows normal syntactic conventions for most modern, high-level programming languages, such as Python, being formed from statements and expressions.
Statements are as follows:
x : y;
- Sets variablex
to the transformation of the valuey
.[3]? x {y}
- Ifx
is truthy, runs the code inside ofy
. Can optionally contain an else clause by appending% {else}
to the end. Ifx
isn't truthy, the code insideelse
will run.& x {y}
- Whilex
is truthy, runs the code inside ofy
.
Expressions work in a similar manner to most programming languages, their special behavior specified below:
- Arithmetic (
+ - * and /
) interprets both operands as BigInts. - Concatenation (
..
) appends the bytes from the right operand to the left operand. - Unary NOT (
!
) sets all the bytes in the value to their inverse (!byte).
All expressions are non-mutable, and return a brand new value when used.
Functions
Function declarations are treated as expressions, similar to variable assignment. They follow the syntax <args..> -> {block}
.
Functions may be called by doing `name(args)`. If calling them as a statement, a semicolon is required at the end. Same with variable assignment.
You may return from a function call by calling a return statement, depicted as <-
. You may not return a value.
Builtins
Luminol contains 4 builtin functions. These serve as a means of displaying information to the user, and gathering input from them, aswell.
The distinction is due to how values are stored. As they take the same form, one could print a value in both numerical and string form, and get different outputs. These functions allow for reading/writing inputs in both formats.
Function | Use |
---|---|
prints(text) |
Prints the value text as a string to the terminal.
|
printn(num) |
Prints the value num as a number to the terminal.
|
inputs(prompt) |
Prompts the user for prompt , then accepts string input from stdin.
|
inputn(block) |
Prompts the user for prompt , then accepts numerical input from stdin.
|
More may be added in the future.
Example Programs
Hello World
prints("Hello, World!");
Cat Program
result : inputs(""); prints(result);
Alternatively, this one goes on forever:
& true { result : inputs(""); prints(result); }
Truth Machine
input : inputn(""); & input { printn(input); } printn(input);
Implementations
The official interpreter can be found over on codeberg[1]. It is stable, but not fully functional (division is not yet added, etc.)
Instructions on how to build it are on the codeberg page.
- ↑ The name comes from the Steven Wilson song of the same name.
- ↑ If this language gets popular enough, or some kind soul makes a pull request thats adds them, i'll gladly add support for them.
- ↑ This doubles as an expression (without the semicolon) that allows for values to be set while the expression is being evaluated. When evaluated, it simply returns the value of the transformation.