User:Theki/Dummy
Dummy is an esolang created by User:Theki in 2022. It is syntatically similar to Lua, but is different in that operators are limited to one character and function and variable names must be three characters exactly; no more, no less. Additionally, data types and default functions are meant to sound as confusing as possible to mimic the experience one gets by looking at code for the first time.
Syntax
In Dummy, things that contain bits of code inside of them (such as functions and if-statements) generally follow the structure of the three-letter-word describing the action, something inbetween, and the world act.
act, among other words used for data types, functions, methods, and syntax, are reserved keywords. This means you have less than 16,000 variable names at your disposal, so use them wisely.
Variable Declaration
Variable declarations are formatted as follows:
[data type] [3-letter name] [value]
As an example, to create a string you would say something like LAR msr "My string". Variables cannot be undefined upon declaration. They must be made empty, such as "" for an empty LAR or ## for a BST.
Functions
tds [return type] [3-letter name] act [function code] end
If you want your function to use arguments, append wth after the function name, then state arguments with the data type followed by its three letter names. Consecutive arguments do not require commas before them. Methods are created in the same way you would create a normal function, except that one of the arguments must reference the value being acted upon. This argument is represented with a dollar sign prefixing its type.
tds ISM add wth $ISM in0 ISM in1 act smd(in0 + in1) end tds LAR sam wth $ISM in0 act LAR str "" chk in0 ? 4 act str = " is 4" els str = " is not 4" end smd(ltl(lar(in0),str)) end 5$add(2) :: 7 5$sam() :: 5 is not 4
Conditional statements
Conditional statements take two forms: an if statement, and a switch statement.
If statements function as a regular code block, using the keyword chk, the condition, and then act. It is terminated by end. Switch statements are a bit more complicated. They are started using fac, the case, and then act. From there, specific cases are structured as ordinary if statements, except the chk is replaced with tes.
chk 5 + 5 ? 10 act sts("I am very good at maths") end ISM num 1 fac num act tes 1 act sts("One is a lonely number") end tes 2 act sts("Two is the foundation of even numbers which are the greatest thing") end tes 3 act sts("Hate.") end end :: Above will print "One is a lonely number"
Loops
While loop
While loops are prefaced with whl, with the condition and act going immediately after.
:: Make an array with numbers 0-9 tds MSN nar act MSN thg {} ISM ind 0 whl ind \ 9 act thg$iim(ind) itt(ind) end smd(thg) end
For-in loops
For-in loops are especially handy when extracting data from MSNs.
for [3-letter element variable name] ext [MSN] act
The element-variable name is essentially a name to represent the current element selected by the loop. As an example, to print every element of an MSN individually, you would do something like this:
tds SIF aex wth MSN mar act for elm ext mar act sts(elm) end end
Data Types
Dummy has seven data types; LAR, ISM, DTM, MSN, BST, SIF, and SAV.
Data type | Equivalent | Description | Stands for |
---|---|---|---|
LAR | String | A simple string that is enclosed in quotation marks. | Letter Array |
ISM | Integer | A 32-bit signed integer. Nothing too special about it. | Number Simulation |
DTM | Boolean | A boolean, represented by YEA or NAH. | Debatable Truthiness Measurement |
MSN | Array | An array of objects of any kind, enclosed in curly braces. | Make Stuff Neat |
BST | Map | A key-value pair object enclosed in hash symbols. | But Seriously Though |
SIF | Null | Nothing. Used when not giving a variable a value upon assignment, or when a function has no return value. | Seems I Forgot |
SAV | <T> or Object/Class | Any/unknown type. Used for inputs with unknown data types, changes data type when set to something that isn't a SAV; this is irreversible. | Some Automatic Variable |
Built-In Functions
Standalone
These functions can be called by themselves in any situation.
Function | Arguments | Description | Stands for |
---|---|---|---|
sts() |
SAV | Print to console | Say This Stuff |
smd() |
SAV | Return; in functions | Show Me Data |
nrd() |
None | Take input from user and return it as a SAV value | No Really Dude |
iot() |
SAV | Inverts input; if not a DTM, just takes whether its truthy or falsy and returns the opposite | Inverse Of This |
ltl() |
LAR LAR | Concatenate two LARs into one and return it | Link These LARs |
lar() |
SAV | Convert a value into a LAR and return it | None |
dtm() |
SAV | Convert a value into a DTM based on its truthiness | None |
itt() |
ISM | Increment a number and return the result | Increment To This |
dtt() |
ISM | Decrement a number and return the result | Decrement This Thing |
hlt() |
SAV | Return the length of a value | How Long This |
gti() |
MSN ISM | Return the value at the specific index of an MSN | Get This Index |
gtv() |
BST LAR | Return the value at the specific key of a BST | Get This Value |
wit() |
SAV | Return the data type of a value | What Is This |
cpi() |
ISM ISM | Return a random number between the minimum (argument 1) and maximum (argument 2) | Conjure Pure ISMs |
pts() |
SAV | Parse a SAV and return a value with the proper data type | Parse This SAV |
iim() |
MSN SAV | Push a value into an MSN | Insert Into MSN |
baw() |
LAR LAR | Split a LAR into an MSN, using the second argument as the separator | Break Apart Words |
Methods
These functions are linked to certain values and can be called by appending the data with a dollar sign, then calling the function.
Function | Arguments | Used on | Description | Stands for |
---|---|---|---|---|
$itt() |
ISM | LAR, MSN | Increment a number by the first argument | Increment To This |
$dtt() |
ISM | LAR, MSN | Decrement a number by the first argument | Decrement This Value |
$hlt() |
None | LAR, MSN | Return the length | How Long This |
$gti() |
ISM | MSN | Return the value at the specific index | Get This Index |
$gtv() |
LAR | BST | Return the value at the specific key | Get This Value |
$wit() |
None | SAV | Return the data type | What Is This |
$iim() |
SAV | MSN | Push a value | Insert Into MSN |
$baw() |
LAR | LAR | Split into an MSN, using the first argument as the separator | Break Apart Words |
An example usage of these functions would be the following:
MSN arr {"foo","bar"} arr$gti(1) :: Returns "bar"
Examples
Truth-machine
tds SIF tmc act SAV inp nrd() inp = pts(inp) chk inp$wit() ! "ISM" act smd() end chk inp ? 0 act sts(0) smd() eif inp ? 1 act whl YEA act sts(1) end end end
To-do
- Describe syntax
- Explain operators