User:Yayimhere/Penpal

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

Penpal is a multithreaded esoteric programming language which "fixes" the "problem" of "which thread do we interpret first?". It does this by having only on thread which can "thread" together the variables of different threads, of which it name come's from.

Algorithm for generating threads

First the non-main threads are generated. They are made by separating threads where variables dont cross reference to each other, with the following preferences:

  • Less threads are preferred to more
  • A smaller main thread is preferred to a smaller one
  • A main thread must exist
  • Atleast two non-main threads must exist

For example, in(this code is not actual Penpal code):

1 a+=b+c
2 a-=c
3 b+=1
4 goto 1

Here, there are two threads:

thread 1: line 2
thread 2: line 3

and the main thread is made up of the code:

1 a+=b+c
2 goto 1

these are auto named and auto line numbered. As you can see, because goto 1 goes to a line part of the main thread, it must also be part of it. Naming is done by using all variable in the thread, ordered up to down and left to right in the code. So thread 1 would be named ac The main thread is repeated as many times as the longest thread, removing any lines if the repeating becomes longer than the longest one.

Execution of threads

Each thread has a line counter, which is referenced as *._name, and its length is +._name, with the "longest length" being #._name. First, each line counter is initialized to 0. Then, all are incremented. Then, for all threads other than the main one, it is checked if *._name == +._name. If true, that thread is eliminated and no longer exists. Else, that lines equal to *._name is ran, and then the current line of the main thread is ran, specifically after all the other ones. But is executed as if it was "in" the program, like for example, a goto.

Instructions and variables

variable's initially are 0. As such there's no "pure assignment operator". Currently, the instruction is incomplete.