XERO

From Esolang
Jump to navigation Jump to search

XERO (the name being the amount of use you'll get out of this language before giving up) is an esolang by User:BoundedBeans which aims to be as annoying as possible, achieved through required nested try-catch blocks, a strange tritwise operation, and dynamically sized tape.

Tape

The tape is a tape of trits, but it is not infinite. The pointer must be at least three tiles away from the top (yes, we're using up and down, not right and left). If the pointer is any further right than that, Error 0 is thrown and the pointer is moved to the bottom cell for the catch block. If the pointer falls off the bottom, Error 0 is thrown and the pointer is moved to the bottom cell for the catch block. The tape initially starts out as empty, meaning you'll need three nested levels of try-catch to even run the program.

The pointer can be moved up with ^, and down with v.

Tritwise operation

The only tritwise operation takes three inputs and gives one output.

Inputs are ordered bottom to top.

This is the table of the first two inputs. First input is on the top.

  0 1 2
0 2 2 0
1 1 2 1
2 0 0 1

The third input follows these conditions:

  • If it is 0, use the table above without any changes.
  • If it is 1, put the table upside down, without horizontal perspective reverse.
  • If it is 2, swap 1s and 2s.

Additionally, if all inputs are 2, throw error 1, in addition to giving the normal result of 2. If errors 1 and 0 happen at the same time (due to all three arguments being two and the pointer ending up too high), throw error 0.

The tritwise operation effectively replaces the arguments with the result, meaning you lose two cells in the process. The pointer is moved to the result's position.

The tritwise operation can be performed with !

I/O

Two commands:

$ - outputs the trit as a bit of an ascii character (2 is treated as 1)
# - inputs a bit and converts it to a trit

Try-catch

Try-catch is the thing that makes this entire language usable. A try block searches for errors, and if it finds one, breaks and sends control to the catch block. However, if the try block does not throw an error, the catch block runs as if it was error 2. A catch block starts by moving the pointer to the bottom, and then adds the error id to the top of the tape. After the catch block ends, the top trit is removed. The error can be used like any other trit, though it can't be directly accessed without additional nesting since that would require moving the pointer too high.

Try-catch syntax is:

{trycode|catchcode}

However, none of the language so far allows for looping or infinite resizing of the tape. The @ command recurses the innermost try-catch block if the current cell is not 0. This can go to as many levels as desired. Every new recursion is treated as a completely separate nested try-catch block, meaning a higher level can catch the errors thrown by a lower level's catch block, and every level adds an additional trit to the top. This accomplishes looping/conditionals as well as expanding the tape arbitrarily, allowing for potential Turing-completeness.

Examples

I don't even know how.