Plea

From Esolang
Jump to navigation Jump to search

Plea is a high-level esoteric programming language created by User:UnavgAustralian on the 3rd of December 2025. It is named due to the fact that you have to beg the program to run.

Syntax

Beg

Every Plea program must have its first line be

beg "enter begging here"

in order for the program to run, plus the begging must also be sufficient for the program to run. So you can't just type anything in.

Functions

Plea functions are defined like this:

fnctn returns <expr> nm <name> args <parameters> calls
    <function code>
;

The value in returns is the return expression of the entire function, which will fire once the function ends.

The name is the name of the function, the parameters are the parameters of the function, and the function code is the function code.

The parameters are defined like this:

let <name> <in/out> <type>

Where <in/out> is used to specify the direction of the parameter, 'in' means that the value is inputted externally, and 'out' means that the value is outputted to an external call. The first out parameter and the return value also must match, or the program will refuse to run.

The main function

The main function in Plea is usually defined like this:

fnctn returns 0 nm main args let v in void calls
    <main code>
;

And it is the entry point for all Plea programs, and as such, it must call itself (which won't actually call itself) or the program will stop since it will assume you didn't want to call main.

Then

Instead of using a semicolon to end instructions, you use 'then', since a semicolon immediately ends the function.

Calling functions

Functions are called like this:

call <function_name> in <input_variables (required)> endin out <output_variables (optional)> endout

You can use parameter syntax for output variables.

Putting in 'input' as an input variable prompts the user for input.

Built-in functions

The built-in functions are print and let_all_hell_break_loose. Print takes an integer or an array of integers and let_all_hell_break_loose randomises the execution order of the program until it crashes.

Variables

Variables are defined like this:

let <name> = <value/shorthand_type>

The shorthand types are: i for int, f for float, and c for char.

If you assign a variable to a value, Plea will automatically choose a type for the variable. If you assign a variable to a type instead of a value, Plea will automatically set the value of that variable to that type's default value (0 for ints, 0.0 for floats, and 0 for chars). There are no strings in Plea, so you have to use a char array instead.

let hello = "Hello" << Illegal!

You might be saying, "Why is the default default value for chars a number?" It's because chars are internally just integers, so if you declare a char like this:

let h = c then
chg h,72

Then h will internally just be 72, and not 'H'.


Arrays

Arrays are defined with their type plus '[]', you cannot assign a value to them but only to their elements, which must be defined separately, for example:

let int_array = i[] then
let int_array@0 = 1 then
let int_array@1 = 2 then
let int_array@2 = 3

'@' means at index.

You can also refer to the first element with just the name of the array. Referring to the array itself requires using '[]' after the name.

You also have to declare its length separately, or the program won't know how long the array is, the length is declared like this:

let lng of int_array = 3

Changing variables

Variables' values can be changed using 'chg', which is used like this:

chg <variable>,<new_value>

You can also chain changes, for example:

chg a,chg b,c

Which changes a and b to c.

Math

In plea, there is no multiplication, division, modulo, bitwise logic, etc. There are only increment and decrement operators, which you can easily repeat with this syntax:

.x<times_to_repeat>

The number of times to repeat an operation can be represented by a number or variable, and you can even repeat repeats, which makes multiplication a bit easier. There is a self symbol ('*'), which can be used in 'chg' to refer to the variable being changed, for example

chg a,*+

increments a by one. And this multiplies a by itself plus one:

chg a,*+.x*.x*

Control flow

There are no if statements or loops. Instead there are when statements and jumps. When statements are declared with this

when <variable> <is/is not> <value>

at the end of any statement or expression, and executes the statement whenever the condition is met, if it is never met, the program refuses to run.

Jumps are declared with 'jmp' plus the line to jump to, not as a number, but as an expression similar to a math expression but without repeats, and with '_' as the self symbol instead of '*'. For example

jmp _++

jumps 2 lines forward, and this

jmp _--

jumps 2 lines backward.

Jumps are expressions, which means you can use them in returns, setting variables, and changing variables.

Jumps still have to use 'then' after them, except for jumps that go to the end of a function.

Catch

Catches are used after a line to make the program ignore any instance of the value in the catch in that line. Catches should be predominantly used with when statements, since you can also catch errors with them, for example

chg a,0 when b is 1 catch error

will change a to 0 whenever b is 1, but if b is never 1 the program will not refuse to run because of the error being caught.

Here is another example of catch but not with a when statement:

let a = 20 catch 0

This code will set a to 2 instead of 20 because of the 0 being ignored.

Defl

Defl means 'defined later', and can be used for basically anything, for return values, values of variables, function names, variable names, calls, etc. It signifies to the program that the thing after it is defined later, for example

fnctn returns 0 defl nm ...

makes the function's name classified as defined later, but if it is never defined later, the program will refuse to run, but you can do this

fnctn returns 0 defl nm catch error ...

in order for a function's name to be able to be permanently 'defined later'.

You are probably wondering, "Can you call a function or reference a variable that is defined later?" And the answer is yes, when a function or variable is 'defined later', it gets automatically assigned with a default name ('undefined_<number>' for functions, and 'undefined_var_<number>' for variables), and you can refer to that function or variable name with that name.

"But how can you make a function or variable's name not defined later", you might say. Well, you can use this syntax:

undefined_<number>.name = <defined_name>

You cannot use this syntax for anything else, only for defining things that are 'defined later'.

Anonymous calls

Calls can also be used to declare an inline function without a name, they can also be used in expressions using 'return', which returns the value placed after it. Here is an example of an anonymous call:

call print in call let a = c[] then let a = 80 then let a@1 = 108
                               then let a@2 = 101 then let a@3 = 97
                               then let lng of a[] = 4 then return a[] endin

Comments

Everything outside of a function is a comment, except for 'beg'.

This is a comment
fnctn returns 0 nm main ...

There are no other ways to make a comment.

Weird intentional behaviour

Changing a variable without chg

If you try to change a variable without 'chg', like this:

a = 3

Then, if the variable is defined, it changes the value tied to that variable to the value. For example, if a was 2, then this will change the number 2 to the number 3. If the variable is not defined, then it changes the character (and integer) with the sum of the ascii values of the variable's name to the value as an ascii value. So this would change the letter 'a' (or the integer 97) to the end of text character (or the integer 3). The same also occurs if you try to change an undefined variable using chg, but not to variables that are 'defined later'.

Using then with a jump to the end of the function

If you use 'then' with a jump to the end of the function, it will execute the following code after the function, potentially causing some intentional behaviour described earlier.

Example Programs

Hello, world!

beg "Enter beg text here";

fnctn returns 0 nm main args let v in void calls
    call main in void endin then
    call print in call let h = c[] then let h = 72
                  then let h@1 = 101 then let h@2 = 108
                  then let h@3 = 108 then let h@4 = 111
                  then let h@5 = 32 then let h@6 = 87
                  then let h@7 = 111 then let h@8 = 114
                  then let h@9 = 108 then let h@10 = 100
                  then let h@11 = 33 then let lng of h[] = 12
                  then return h[] endin
;

Cat program

beg "Enter beg text here";

fnctn returns 0 nm main args let v in void calls
    call main in void endin then
    call print in input endin then
    jmp _- then
;