Bullshit

Paradigm(s) Functional Ashli Katt, zozi 2023 Unknown Unimplemented `.bullshit`

Bullshit is a barely-functional, functional language designed with nothing in mind. It's based on nothing. It is designed to be as bullshit as possible while remaining a usable language.

Overview

A Bullshit program is a web of expressions, with program execution beginning at the expression denoted BS. An expression is written like one of the following:

```T                   T
\                 /
O               O
\             /
O           O
\         /
O       O
\     /
T   T
```

Where `T` is an expression type, and `O` are the expression parameters. An expression must have at least 1 parameter. Expressions must be diagonal. Operator order is always top to bottom unless stated otherwise.

Any `/` or `\` may be any length to allow the program to fit.

The only datatype is unsigned 64 bit integers. Values 0 through 9 may be represented in code by their digit as a literal value.

Defined Expressions

There are a handful of defined expressions in Bullshit, the mathematical operations are as follows:

```+  -  *  ;  %  <  >  ~  |  &  ^
\  \  \  \  \  \  \  \  \  \  \
A  A  A  A  A  A  A  A  A  A  A
\  \  \  \  \  \  \  \  \  \  \
B  B  B  B  B  B  B  B  B  B  B
\  \  \  \  \  \  \  \  \  \  \
+  -  *  ;  %  <  >  ~  |  &  ^
```

In order from left to right: Addition, Subtraction, Multiplication, Division, Modulo, Left Bitshift, Unsigned Right Bitshift, Bitwise NOT, Bitwise OR, Bitwise AND, Bitwise XOR. They return their relevant value from their prongs.

Note: Division or Modulo by 0 will return 0.

The mathematical operations accept any number of parameters, a parameter for an expression may be one of the following:

1. A literal digit
2. Registers A, B, C, X
3. An expression prong (Explained later)

There are two top-level expressions in Bullshit that act as the beginning of execution.

```B  T
\  \
E  E
\  \
E  E
\  \
S  ?
```

The `BS` expression takes any number of parameters and will evaluate them in order. It acts as the entrypoint for code. The `T?` expression creates a new thread type. Replace the `?` with a symbol to represent it. A thread will execute its input expressions in order when spawned. Threads are not synchronized in any way and it is up to the programmer to organize execution if threads are needed to interact.

```S  B  O  R  P
\  \  \  \  \
A  A  A  A  A
\  \  \  \  \
B  B  O  ?  P
\
C
\
?
```

The `S?` expression will spawn a new thread with its A, B, and C registers set to the 3 inputs. The type of the thread is determined by the character used for `?`. It returns 0 from its prongs.

The `B` expression will halt the thread if and only if its input is 0, otherwise it will return the input from its prongs.

The `O` expression will push the UTF-8 value of the input value to the output buffer.

The `R?` expression will set the value of the register with name `?` to the input. `?` should be A, B, C, or X.

The `P` expression will pause the current thread for the input amount of milliseconds, it propagates 0 from its prongs.

Expression Prongs

An expression's type is also referred to as a prong. When an expression is evaluated, its return value is propagated to its prongs, which can be used as parameters for other expressions. Here is an example:

```          +
/
*       9
\     /
2   4
\ /
+
\
*
```

The `*` evaluates the product of 2 and the output of the secondary expression. The secondary expression return the sum of 4 and 9 and will propagate that value from its prongs to the `*` expression so it can complete evaluation.

This expression is equivelant to `2 * (4 + 9)`, evaluating to `26`

Registers

The registers `A`, `B`, and `C` are local to the thread. The register `X` is global across all threads. All registers hold a single 64-bit integer and are all initialized to 0, with some exceptions.

IO

A Bullshit program accepts a single string as input, the string is first converted to its UTF-8 byte representation, and then a new main (`BS`) thread is spawned for each byte. The `A` register of a given thread is equal to the value of the byte, and the `B` register of that thread is equal to the 0-based-index of that byte in the input string.

The program terminates after all threads have ended.

Examples

Truth Machine (Note: This is actually wrong, will fix soonish :3)

```           ;                      *
/                      /
-       B               -       6
\     /                 \     /
1   B       [           A   8
\ /       /             \ /
;   B   A   ]           *   C
\ /   /   /             \ /
B   -   0   A   -   T   -           ]
\ /   /   /     \   \ /           /
B   0   0       1   R           0
\ /   /         \   \         /
B   S   0           ;   B       0
/     \ /           / \ / \     /
T   C   O   S           C   -   O   0
\ /   /     \         /   /   / \ /
B   *       S       C   B   *   T
\ / \             /       / \   \
O   7           ;       O   8   ]
\   \                       \
[   7                       6
\                       \
*                       *
```

Closing Remarks

In case you ever feel safe, remember that this language is out there.