tError

From Esolang
Jump to navigation Jump to search

tError is an esoteric programming language by User:BoundedBeans where the only data type is errors.

Storage

  1. The reset counter (an unbounded integer) default 0 (it can be negative)
  2. The current error defaults to an error with empty text and no parent
  3. The error stack
  4. The current character (only for input), by default ‘x’

Recommendations for implementations

It is recommended that an implementation of this language does not actually use errors as a datatype (such as Java’s Exception class), since they might not have the proper functionality. A better way would be to store an array of strings storing the current error and all of its parents.

Syntax

The program begins with a list of error texts, separated by newlines. They support the escape sequences \" \n \\. This will be pushed to the stack before the program runs, in order. These should be all of the error texts you intend to use in the output, however errors can be duplicated just fine (you’ll just never be able to output anything else). If you want, you can wrap them all up in the parent link.

Then a blank line should be typed, followed by the instructions.

Instructions

: - duplicate the top error. This should make a copy of the error and all of its ancestors, there should be no duplicate references
/ - swap the top two errors
$ - pop the top error
R - move the top element 8 places down
} - pop the top element, push the parent
{ - pop x, pop y, push a copy of x with y as the parent. If x already has parents, discard them
T - print “A fatal error has occurred. “ followed by the error 
    text of the top error on the error stack, followed by a newline.
    Pop the top element off of the stack, put it in the current 
    error, reset the stack to its original configuration, and 
    increment the reset counter. This throws the error.
    This is the only way to output and put things into the current error.
C - push the current error onto the stack, resetting the current error to the default
I - input into the current character
~ - use the next character. If the current character does not 
    match that character, skip the code until the matching )
< - if the reset counter is zero, jump to the matching >
> - if the reset counter is non-zero, jump to the matching <
D - decrement the reset counter
+ - increment the reset counter and print “WIMP!”
! - if the absolute value of the reset counter equals the number of parent 
    levels on the top error of the stack, jump reset counter * 10 
    instructions backwards. This can potentially be useful 
    for testing values in Minsky machine implementations.
    If the reset counter is negative, go forwards

Try-catch

In TError Specification 2.0, a new and very important feature is added, try-catch. Try-catch can function as a way to print better, as a conditional, and as functions.

Try-catch blocks are named, and are skipped completely when the instruction pointer reaches it. However, using the c command (lowercase c, uppercase does something different), followed by the name. When an error is caught, it is printed without the fatal error prefix or the newline unless it begins with ###, in which it is not printed at all.

Syntax

Try catch blocks are enclosed within square brackets, with the first four characters after the opening bracket are the name. The next code up until the | character is the try block. All vertical bars begin a catch block, followed by an error text in double quotes to check for. The string can be "@ANY_ERROR" to catch any error not caught by other clauses. The empty string can be used to not catch any error since an error text cannot be empty. It is an error if try-catch blocks are nested, but you can effectively accomplish the same thing when you call one from another.

Call stack

Whenever a try-catch block is called, the position of the instruction pointer before the jump is put onto the call stack. When a try-catch block finishes, it pops from the call stack and jumps back to the original position. Looping can be accomplished by recursion. Since try-catch allows conditionals and recursion can simulate looping, this is unintentionally a lot like Javagony.

Computational class

TError is Turing-complete, since it can up to an 8-register Minsky machine through the amount of levels of parents of an error. We need to be able to go-to wherever, luckily we can have numbers substitute for zero, and that number can change as long as we always change everything at once when it does.

Here is a 2-register:

inc 1: :{
inc 2: /:{/
dec 1: }Q!
dec 2: /}Q!/

Where Q is replaced by a series of either :{/:{/+ (increment) (if you’re willing to be a wimp) or }/}/D (decrement) bringing the go-to to a correct position. Increment can not really be simulated without wimpmode since one of the registers would lose their number.

Examples

Hello world

Hello world!

[hw--T|"@ANY_ERROR"]chw--

Truth-machine

1
0

I~0c0---)~1$c1---)[0---T|"0"][1---:T|"1"c1---]


TError Joust

TError Joust is a game inspired by BF Joust. The rules are:

  • Two programs are chosen, A and B, which both lack initial stack contents.
  • Both A and B are banned from using try-catch or c.
  • The two programs are interleaved character by character.
  • Angle bracket and ~) depth is counted throughout the resulting program.
  • Any points where the depth goes negative, the character is removed.
  • Brackets are inserted at the end to match them.
  • The initial stack contents are set to:
A
B
C
C
C
A
B
C
C
C
C
  • When the error A is thrown for the 5th time, A wins.
  • When the error B is thrown for the 5th time, B wins.
  • If at any point either error A or B does not exist, it is a draw.
    • As long as it exists on the stack, as an error parent, or in the current error, the game is not a draw yet.
  • After 500000 instructions have been run and there is no winner, it is a draw.
  • Input is allowed, is decided at the start of the game, and may determine the result.