Reversible-2D is a 2D programming language which can be reversed. It is unique because it still has variables. The short for Reversible-2D is R2D. For version 1, it is R2D1. When version 2 comes, some ppl will lol. It is made by TehZ.
The current commands:
\ and / Mirrors. P Swaps the value of the current thread and the next cell in the source code. O Outputs the value of the current thread. I If the value to the right of this command is not space, throws an error. If it is space, this will read a byte from stdin and put it to the cell to the right. + Adds 1 to the value of the current thread. - Opposite of +. ¤ Ends the current thread. After a thread is terminated, it counts how many steps it has been terminated. N Prints a newline character to stdout. Other Nothing.
Commands are reversed by:
\ and / Moving the other way through. P Repeating the process. O Removing last printed character from console/file. I Taking the value of the cell to the right of the command and putting it into the threads value. + Doing - instead. - Doing + instead. ¤ Starting the thread and turning it around (after the amount of steps it has been terminated :D). N Same as O. Other Nothing.
Commands are CaSe-SeNsItIvE!
A thread in R2D is not a normal thread, because all threads execute in the same process. They are placed in the source with the following commands:
V Down > Right ^ Up < Left
A thread holds a 16 bit value (because java char's is 16 bit) which can be changed through the commands.
Threads will execute in a fixed and well defined order:
Y is first priority The lower Y coordinate at start, the sooner a thread will run. X is second priority The lower X coordinate at start, the sooner a thread will run.
Note on Threads
If a thread collides with a thread starting point in the same direction as the thread, there will come undefined behavior. If it was allowed, Reversible-2D would not be reversible.
There is two places that variables can be:
Source Each cell is a variable. Threads Each thread is a variable.
The above program will write "Hello, World!" followed by a newline.
Cat (ignoring eof):
/ > \ \O I/
The above program will copy all input to output. *NOTE* It will actually produce undefined behavior, but it works in the standard interpreter.
>PHOPeOPlOPlOPoOP,OP OPWOPoOPrOPlOPdOP!ON¤ >PHOPiOP!ON¤
The above program will write "HHeil!" followed by a newline, followed by "lo, World!" followed by a newline.
Reversible-2D is not Turing-Complete, because any program can either always terminate or always loop forever (but a forever loop gives undefined behavior).