tError

From Esolang
Jump to navigation Jump to search

tError is an esoteric programming language by User:BoundedBeans where the only data type and method of flow control are 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. 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 y 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 reset counter is equals the number of parent 
    levels on the current error, 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


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.

Examples

Hello world

This also prints “A fatal error has occurred. “

Hello, world!

T

Truth-machine

Prints “A fatal error has occurred. 0” if zero, “A fatal error has occurred. 1” infinite times if 1.

1
0

I{~0T)~1}T<CT>)