Dango

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.
🍡Dango
Designed by User:RaiseAfloppaFan3925
Appeared in 2025
Memory system Stack-based, Hash table-based
Computational class possibly Turing complete (unproven)
Reference implementation [1]
Influenced by C++ (function syntax), OCaml (comments)
File extension(s) .dango, .🍡

Dango is an esolang by User:RaiseAfloppaFan3925 that revolves around dango, a Japanese rice-based dumpling.

Syntax

Dango's syntax is based on dango, so most instructions (other than three) are placed in dumplings that must have trailing sticks made of four minus signs. (----)

Comments can be done with [* comment *], and they can be nested.

Labels can be defined with an identifier prefixed with a @. When referred to in a GOTO instruction, the string must also have the at sign.

Values

Dango has six types of values: 64-bit integers that wrap around on overflow, 64-bit IEEE 754 doubles, strings, string-value tables, lambdas, and native functions.

Functions

Dango functions (which are anonymous) can be declared using a syntax based on C++'s lambda syntax.

[] {
    [* body goes here... *]
}

Operations

Dango operations operate on the stack.

Name Dumpling Operation
Addition (+) Pops the two top values off of the stack and adds them. If both values are strings, then they are concatenated. If the top is a table and the value below that is a string, then the value below the string is inserted into the table with the key being the string.
Division / Pops two values from the stack and divides them.
Equal (=) Pops two values from the stack and checks if they are equal.
Getattr ($) If the top of the stack is a string, then it retrieves the corresponding global variable. If it is a table, then the value below it (which must be a string) is used as a key to get a value from the table.
Goto (@) The operand must be a string. The operand is treated as a label and execution jumps to the label with the same text, and it is discarded. If the operand is not a string or is a nonexistent label, an error is thrown. It is undefined behavior to use (@) Goto inside of a dango that is used as a parameter for a serve or eat statement. (@label)(@)---- eat. is valid, but eat (@label)(@)---- is not.
Multiplication (*) Pops two values from the stack and multiplies them.
Multitool (#) What this does depends on the type of the stack top. If the top of the stack is a function, then it calls it. If it is a string, then it converts the first character into an integer with its Unicode codepoint. If it is an integer, then it converts it into a string with one character, being the Unicode character with that codepoint. If it is a table, then it gives the number of entries in the table. In all cases, the operand is discarded.
Select (?) If the top of the stack is truthy, it pops two values from the stack. Otherwise, it pops once, preserves the second value, and removes the value below that.
Stringify (') Converts the top of the stack into a string
Subtraction (-) Pops two values from the stack and subtracts them.

Along with the dumpling operations, Dango also has keyword operations (for a lack of a better word).

consume

consume takes one line of input from the user and pushes it as a string, without the newline.

eat

eat generally discards the arguments given to it. However, it has two types.

When given a dango like in the example eat (some)(operations)(here)----, it will discard all of the values produced by that dango. Even if the dango produces a dynamic amount of values, they will all be discarded.

When given no dango or if a dot character is placed in front of it (like in eat. (This will not be discarded)----, it will only discard the top of the stack.

serve

serve has the same behavior and same cases as eat, except instead of just discarding the values it also prints them.

serve (1)(2)(3)----

The above will print 321 since it starts printing from the top of the stack, and 3 was the last value pushed putting it at the top of the stack.

Standard library

The standard library now lives inside a table in a global variable named libstd.

Chrono

Currently, libstd.chrono only has one function, sleep. It takes in a number and sleeps for that many seconds.

Env

libstd.env only has one member, args. This contains the argument vector passed to the Dango process. It is a table with the indices being stringified numbers starting from zero.

Math

The math library libstd.math has only five functions, sin, sqrt, deg2rad, rad2deg, and hypot. However, it supports many math constants such as pi, tau, Euler's number, Euler's constant, the lemniscate constant, and the golden ratio.

Examples

Hello world program

serve (Hello, world!)----

Truth machine

consume (@0)(@1)(2)(\)(0)(')(=)(?)(@)----
@1
    serve (0)(\)----
    (@1)(@)----
@0
    serve

Cat program

consume serve