Thotpatrol

From Esolang
Jump to: navigation, search

Language overview

thotpatrol is a thematic high level programming language designed with the intent of forcing the programmer to use bad practice if they hope to accomplish anything. The core eccentricity of thotpatrol is the specification that variables can only be named from a pre-approved list of variable names, and that this list of names cannot be programatically accessed. This constraint makes arrays impossible without a specialized library to programatically construct and dereference variable names in a trial and error method. The convention is that the list of allowable names is a list of female names which can be represented in Unicode. The language is meant to illustrate a dystopian world where the programmer is not only extremely isolated from the hardware, but the high level structure of the language imposes malignant and arbitrary constraints. Thus the programmer is locked in a high tower, and must despite this predicament make usable code through feats of human ingenuity and extremely bad practice.

Variable types

In total, there are three types, all treated as primitives.

THOTTY (integer) THAUGHTY (String) THOT(boolean)

to set a variable name to a instance of a given type, type the following line of code:

💦DM💦 <type> <variablename>

Below is an example of a thaughty declaration


💦DM💦 THAUGHTY LAUREN

The following table shows the correct syntax for literals in each of the three types

Type Literal
THOTTY ™123™
THAUGHTY ©someString©
THOT 🉑,🈲 (true and false respectively)

Variable assignment

Variable assignment is defined as follows.

<varname> 🍑📧 <value>

the value may be a set of predicates or values connected by operators, as long as they resolve to a single value of the correct type.

Operator types

Binary operators

The following binary operator types are presented in order of precedence.

Operation Operator Symbol Argument Type Return Type
or INFORMANT THOT THOT
and CONSPIRATOR THOT THOT
== INTERROGATE two arguments of same type THOT
> 👉 THOTTY THOTTY
< 👈 THOTTY THOTTY
>= 🤜 THOTTY THOTTY
<= 🤛 THOTTY THOTTY
* 👪 THOTTY THOTTY
/ 🖖 THOTTY THOTTY
+ 👏 THOTTY THOTTY
- 👻 THOTTY THOTTY
 % 😂 THOTTY THOTTY
concat REDACTED THAUGHTY THAUGHTY
charat 🔎 THAUGHTY, THOTTY THAUGHTY

It's important to note that there is no grouping operator, so in order to group operations, results must be stored as values in predicate variables. Additionally, there are two unary operators, which each take higher precedence that all binary operators. The unary operators are presented in the following table.

Unary operators

operation symbol Argument Type Return Type
dereference 👁‍🗨<THAUGHTY>👁‍🗨 THAUGHTY var name
not 🙃 THOT THOT



Control structure

Start and end lines

thotpatrol programs must have a code header line and closer line, which are respectively as follows

📡JACKING IN📡
🇺🇸REPORT UNPATRIOTIC ACTIVITY🇺🇸

Any text before or after these lines will be ignored by the interpreter; it is standard practice to place a comment header above the code header line.

thotpatrol supports two internal control sequencing structures, similar to the 'if' and 'while' structures found in other high level languages. The syntax is as follows.

If statements

😎BRIEF😎 <THOT value>
<if statement contents> 
🔇DEBRIEF🔇

While statements

❤PRIME ASSETS❤ <THOT value>
<loop contents> 
🎧INTERCEPT MALIGNANT COMMUNICATIONS🎧

User interaction

thotpatrol supports user input and output through the console.

🕵 🍑📧 <varname> 

will output the contents of a variable of any type

🕵 📧🍆 <THAUGHTY name>

will cause the interpreter to wait until user input is entered and read it in as a THAUGHTY value.

Inline commenting

Any text after the '🔥' symbol on a line will be ignored by the interpreter. This enables inline commenting.

Garbage collection

The following code undeclares a variable, destroying the value that variable holds and allowing re-declaration to any type. This is very important for functions in libraries to prevent overlapping declaration.

NAUGHTY <vartype> <varname>

Trial and error execution

🤷 <some code>

The above causes the interpreter to skip the remainder of line if it cannot be parsed or causes illegal operation. Programmatic trial-and error-array declaration would not be possible without this.

Function calls

The following code is used to call a function located in another file in the specified relative directory.

👐 <relative address> 

Note that variable declarations and values are retained in nested function calls, and that once the calle function terminates, it will return control to the caller function. programs can call themselves recursively, but this cause problems if there are repeated declarations of the same variable without garbage collection, as an already declared variable cannot be re-declared. It is generally recommended to use a helper function with no declarations for the actual recursive part of a program's operation.

Syntactical rules

Each newline-separated line is interpreted as an instruction. Newlines in string literals are not counted as structural newlines, and are allowed. Multiple instructions cannot be placed on the same line. thotpatrol files must be saved in UNICODE.

Turing completeness

With a list of allowable variable names equal to the sample space generated by the possible combinations of characters in a variable name, thotpatrol is turing complete in the same sense as another high level language on a finite machine, as 'indexing' is fairly trivial. However, with the mandated restrictions on variable naming, the only hope of limited simulation a proper finite tape is through trial and error variable name generation, which is extremely costly.

Implementation status

Implemented in Java; see External resources.

Example programs

FizzBuzz implementation

The following is an implementation of fizzbuzz in thotpatrol

Mindy Galveston
2/11/annodomini2017
A simple fizzbuzz program

"Write a program that prints the numbers from 1 to 100. But for
multiples of three print “Fizz” instead of the number and for
the multiples of five print “Buzz”. For numbers which are multiples
of both three and five print “FizzBuzz”."

📡JACKING IN📡

💦DM💦 THOTTY CHRISTINE 🔥var declarations
💦DM💦 THOT ALEXIS
💦DM💦 THOT ANNA

CHRISTINE 🍑📧 ™1™ 🔥 counter initialization

❤PRIME ASSETS❤ CHRISTINE 🤛 ™100™

ALEXIS 🍑📧 CHRISTINE 😂 ™3™ INTERROGATE ™0™ 🔥 case logic component assignment
ANNA 🍑📧 CHRISTINE 😂 ™5™ INTERROGATE ™0™

😎BRIEF😎 ALEXIS CONSPIRATOR ANNA 🔥 case logic for fizzbuzz
🕵 🍑📧 ©FizzBuzz ©
🕵 🍑📧 CHRISTINE
🕵 🍑📧 ©
©
🔇DEBRIEF🔇
😎BRIEF😎 ALEXIS CONSPIRATOR 🙃ANNA
🕵 🍑📧 ©Fizz ©
🕵 🍑📧 CHRISTINE
🕵 🍑📧 ©
©
🔇DEBRIEF🔇
😎BRIEF😎 🙃ALEXIS CONSPIRATOR ANNA
🕵 🍑📧 ©Buzz ©
🕵 🍑📧 CHRISTINE
🕵 🍑📧 ©
© 
🔇DEBRIEF🔇
😎BRIEF😎 🙃ALEXIS CONSPIRATOR 🙃ANNA
🕵 🍑📧 CHRISTINE
🕵 🍑📧 ©
© 
🔇DEBRIEF🔇
 
CHRISTINE 🍑📧 CHRISTINE 👏 ™1™ 🔥 counter incrementation

🎧INTERCEPT MALIGNANT COMMUNICATIONS🎧 

NAUGHTY THOTTY CHRISTINE
NAUGHTY THOT ALEXIS
NAUGHTY THOT ANNA


🇺🇸REPORT UNPATRIOTIC ACTIVITY🇺🇸

Recursive iteration example

For this example, assume that the main and utility methods are stored in text files titled main.txt and call.txt respectively.

Main method

📡JACKING IN📡


💦DM💦 THOTTY KAREN

KAREN 🍑📧 ™123™


👐 call.txt

NAUGHTY THOTTY KAREN
🇺🇸REPORT UNPATRIOTIC ACTIVITY🇺🇸

Utility method

📡JACKING IN📡

🕵 🍑📧 KAREN
🕵 🍑📧 © ©
KAREN 🍑📧 KAREN 👻 ™1™
 
😎BRIEF😎 KAREN 👉 ™0™
👐 call.txt
🔇DEBRIEF🔇

🇺🇸REPORT UNPATRIOTIC ACTIVITY🇺🇸

Dereferencing and Variable Handling Example

Mindy Galveston
2/22/anno domini 2017

"A program to extensively test variable handling. 
Will print 42069 upon correct execution."

📡JACKING IN📡
💦DM💦 THAUGHTY GWEN
GWEN 🍑📧 ©KATY©
💦DM💦 THOTTY 👁‍🗨GWEN👁‍🗨
👁‍🗨GWEN👁‍🗨 🍑📧 ™420™
🕵 🍑📧 👁‍🗨GWEN👁‍🗨
NAUGHTY THOTTY 👁‍🗨GWEN👁‍🗨
NAUGHTY THAUGHTY GWEN 

💦DM💦 THAUGHTY GWEN
💦DM💦 THAUGHTY KATY
💦DM💦 THAUGHTY ALEXIS


GWEN 🍑📧 ©KA©
KATY 🍑📧 ©REN© 

ALEXIS 🍑📧 GWEN REDACTED KATY


💦DM💦 THOT 👁‍🗨ALEXIS👁‍🗨

👁‍🗨ALEXIS👁‍🗨 🍑📧 🉑

😎BRIEF😎 👁‍🗨ALEXIS👁‍🗨
🕵 🍑📧 ©69©
🔇DEBRIEF🔇

NAUGHTY THOT  👁‍🗨ALEXIS👁‍🗨
NAUGHTY THAUGHTY ALEXIS
NAUGHTY THAUGHTY GWEN
NAUGHTY THAUGHTY KATY

🇺🇸REPORT UNPATRIOTIC ACTIVITY🇺🇸

External resources

Interpreter, sample programs, and further instructions