Dango
- This is still a work in progress. It may be changed in the future.
please take any inconsistencies with an ocean's worth of salt.
| Designed by | User:RaiseAfloppaFan3925 |
|---|---|
| Appeared in | 2025 |
| Memory system | Stack-based |
| Computational class | likely Linear-bounded automaton |
| Reference implementation | dango |
| File extension(s) | .dango, .🍡 |
Dango is an esolang by User:RaiseAfloppaFan3925 that revolves around dango, a Japanese rice-based dumpling.
Code
Code in Dango are stored in dango (who could have guessed), where each instruction is wrapped in parentheses () (which will be referred to as "dumplings" for the rest of this article, for a lack of a better word) with the line ending with a stick ----.
Operations
"Dumpling" operations
| Operation | Example | Action |
|---|---|---|
()
|
()----
|
Null value. |
(')
|
(')(Hello, world!)----
|
Stringify the last pushed value. |
('c)
|
('c)(10)----
|
Create a Unicode character from the stack top as a code point. |
(j)
|
(j)(4)----
|
Jumps to the line number of the stack top. |
(`)
|
(`)(')(1234)----
|
Converts a value to an integer, returns () if the conversion failed.
|
(;)
|
(;)(')(0.401)----
|
Converts a value to a float, returns () if the conversion failed.
|
(len)
|
(...)(while)(>)(2)(len)----
|
If the stack top is a dango (the data structure), then the amount of dumplings on it is pushed to the stack. Otherwise, 0 is pushed. The value at the top is preserved, unlike with other instructions.
|
Function calls
In Dango, a function call is just the function name preceded by a colon (:) inside a dumpling, with the arguments being stored on the stack.
Example:
(:io-write)(')(stdout)(')(Hello, world!)----
Stack (before function call):
top "stdout" "Hello, world!" bottom
Since the dumplings are pushed to the stack and functions take off of the stack, the arguments to the function can be in separate dango as seen above.
Dango operations
These operations operate on the dango memory in the program.
| Operation | Example | Action |
|---|---|---|
eat
|
eat (')(Hello, world!)----, eat
|
Pops the top of the stack and prints it. |
fetch
|
fetch 2
|
Copies the value N slots down from the top of the stack and moves the copy to the top.
|
remove
|
remove
|
If the top of the stack is a dango, then it removes the value at the end and pushes it to the stack.
Example: skewer 2 (1)(2)---- eat remove eat remove Stack (line 1): top (1)(2)---- (Dango) bottom Stack (line 2, before top 1 (Int) (2)---- (Dango) bottom Stack (line 3, before top 2 (Int) bottom |
skewer <N>
|
skewer 2 (1)(2)----
|
Pops the top N values off of the stack and stores them in a dango that is pushed onto the stack, with the stack top being stored to the left and the value at top_pos - N being stored to the right.
Example: eat skewer 3 (1)(2)(3)---- Output: (1)(2)(3)---- If the amount of values requested to be skewered is greater than 5, then an error occurs. Example: eat skewer 6 (1)(2)(3)---- skewer 2 (4)(4)---- (5)(6)---- Output: error: skewer is too short for 6 dumplings If the amount of values requested to be skewered is zero, then an error occurs. Example: skewer 0 Output: error: cannot have dango with zero dumplings, that's just a stick |
Values
- Null/Nil -
() - Integers - signed 64-bit integers with overflow and underflow
- Floats - 64-bit (double-precision) IEEE floats
- Strings - strings (created by the
(')dumpling) - Raw text - strings, but with parentheses
Dango
The dango (not to be confused with the language and the code unit in the language) is a stack-like data structure. It is limited to a maximum of 5 values, but it can contain more dango. Dangos are constructed with the skewer keyword which constructs a dango out of the top N values.
REPL Example:
--(O)(O)(O) > eat skewer 3 (1)(2)(3)---- (1)(2)(3)---- ()
Here is what happens if a dango contains a dango.
skewer 2 (4)(5)---- (1)(2)(3)---- skewer 4 eat
Output:
(1)(2)(3)[(4)(5)]----
Here is what happens if a dango is constructed with a length greater than 5.
--(O)(O)(O) > eat skewer 6 (1)(2)(3)(4)(5)(6)---- Error: skewer is too short for 6 dumplings --(O)(O)(O) >
Standard Library
For some reason, Dango has a standard library.
I/O
:io-input- can do either(:io-input)(0)which just takes in input, or(:io-input)(1)----where an extra prompt argument is needed:env-args- returns the argument vector passed to Dango
Time
:chrono-now- returns the number of seconds (with milliseconds) since the Unix epoch:chrono-sleep- sleeps for the given amount of seconds (int and float supported)
Math
:math-cos- returns the cosine of a number:math-e- returns the value of Euler's number (approx. 2.71828...):math-pi- returns the value of (approx. 3.14159265358979...):math-sin- returns the sine of a number:math-sqrt- returns the square root of a number:math-sqrt2- returns the value of (approx. 1.41421...):math-tan- returns the tangent of a number
Embedding
Dango can be embedded by adding it as a dependency after downloading from source.
use dango::dango_utils::{
self,
dango_errors,
dango::runtime::{
self,
Value,
Program
}
};
unsafe fn exec_code(&mut self) {
do_stuff();
let mut program = dango_utils::compile_str(&user_input_idk);
match program {
Ok(program) => {
self.spawn_dango_thread(program);
println!("{}", "what do I do");
}
Err(errors) => unsafe { self.handle_err(errors) },
}
do_more_stuff();
}
Example Programs
Hello world
eat (')(Hello, world!)----
Truth Machine
(j)(3)---- eat (0)(while)(=)(0)(:io-input)(0)---- (j)(2)---- eat (1)----
Cat program
eat (:io-input)(0)----
Truth machine
remove (I forgot to fix this program)----
(j)(5)(while)(=)(')(0)(:io-input)(0)----
eat (1)----
(j)(3)----
eat (0)----
Fibonacci number (iterative)
(`)(1)---- remove (Our fibonacci number)----
fetch 0 fetch 0
remove (Fib[n], iterative fibonacci by the way)----
(j)(9)(while)(!=)(0)---- fetch 0 remove (if n == 0 -> 0)----
(j)(46)(0)----
(j)(9)(while)(!=)(1)---- fetch 0 remove (if n == 1 -> 1)----
(j)(46)(1)----
fetch 0 remove (let n = n)----
(0)---- remove (let x = 0)----
(1)---- remove (let y = 1)----
(1)---- remove (let i = 0)----
remove (while i < y)----
remove (top i y x n bottom )----
fetch 2 remove (x)----
remove (top x i y x n bottom )----
fetch 2 remove (y)----
remove (top y x i y x n bottom )----
(+)---- remove (let z = x + y)----
remove (top z i y x n bottom )----
fetch 4 remove (n = n)----
remove (top n z i y x n bottom )----
fetch 3 remove (x = y)----
remove (top x n z i y x n bottom )----
fetch 2 remove (y = z)----
remove (top y x n z i y x n bottom )----
fetch 4
(+)(1)---- remove (i = i + 1)----
remove (top i y x n z i y x n bottom )----
fetch 0 remove (get i)----
remove (top i i y x n z i y x n bottom )----
fetch 4 remove (get n)----
remove (top n i i y x n z i y x n bottom )----
(j)(13)(while)(<)----
remove (end while)----
remove (end)----
eat (')(F()----
eat
eat ('c)(41)----
eat (')( = )----
eat
eat ('c)(10)----
User:RaiseAfloppaFan3925's User-friendly Fibonacci function
(j)(11)(while)(=)(')(exit)---- fetch 0 fetch 0 (:io-input)(1)---- eat (')(Input a number: )----
(j)(1)---- eat eat eat eat (')('exit' to exit)('c)(10)(')('help' to see this)('c)(10)---- (while)(=)(')(help)----
(j)(1)---- eat eat (')(Invalid number. Try again.)('c)(10)---- (while)(=)()---- fetch 0 (`)
(j)(1)---- eat eat (')(Cannot get a negative Fibonacci number. Try again.)('c)(10)(while)(<)(0)---- fetch 0
(j)(1)---- eat eat (')(Resulting value would be too large. Try again.)('c)(10)(while)(>)(92)---- fetch 0
(j)(10)(0)(while)(=)(0)---- fetch 0
(j)(10)(1)(while)(=)(1)---- fetch 0
(1)(1)(0)---- fetch 0
(j)(9)(while)(<)---- fetch 4 fetch 0 (+)(1)---- fetch 4 fetch 2 fetch 3 fetch 4 (+)---- fetch 2 fetch 2
(j)(1)---- eat ('c)(10)---- eat eat eat ('c)(41)(')( = )---- eat eat (')(F()----
User-friendly sleep program
fetch 0 fetch 0 (:io-input)(1)(+)(')( )(+)('c)(58)(+)('c)(41)(')(Sleep for (seconds)----
(j)(12)(while)(=)(')(exit)----
(j)(1)---- eat eat eat eat eat eat (')('exit' to exit)('c)(10)(')('help' to show this)('c)(10)(')(this program takes in a number as input and sleeps for that amount of time)('c)(10)---- (while)(=)(')(help)----
(j)(1)---- remove remove eat eat (')(Invalid duration. Try again.)('c)(10)---- (while)(+)(<)(0)---- fetch 1 (=)()---- fetch 0 fetch 0 (;)----
(-)(:chrono-now)---- remove (:chrono-sleep)---- fetch 1 (:chrono-now)----
(-)---- fetch 1 (0)----
fetch 0
(-)---- fetch 3 eat (')( seconds (error of )---- eat fetch 0 eat (')(Slept for )----
eat eat ('c)(41)('c)(10)---- eat
remove remove remove remove
(j)(1)----