Kayak

Kayak is a reversible esoteric programming language designed and implemented in 2002 by Ben Rudiak-Gould. Any procedure can be run forwards or backwards. Running a procedure backwards is equivalent to reversing its characters.

All many-to-one operations, like sorting, must be implemented by moving the unneeded information into a bit bucket supplied by the system.

Language details
Kayak has two data types: infinite stacks of bits (of which programs can have an arbitrary number) and single-bit temporary registers (only one of which is accessible within a given scope). There are nine symbols recognized in Kayak:

An identifier can be any string that does not include the above symbols and does not include whitespace.

Procedures
Programs are specified as lists of procedures. A procedure definition takes the form

name1(arg1|arg2) { body } (arg3|arg4)name2

Multiple procedures can have the same name1 as long as they have a different name2, or vice versa. Both names are always specified when calling a procedure.

A procedure can take any number of arguments, named both at the start of the definition and at the end. When the procedure starts, the argument names at the entry point (which can be either the beginning or the end) are bound to the arguments supplied, and when the procedure ends, the variables listed at the exit point are updated. The following procedure, for example, swaps its arguments:

swap(a|b) {} (b|a)paws

The commands are:

All local variables in a procedure, except those passed in by arguments, are initialized to contain infinite zeroes. They should also contain only zeroes when the procedure finishes.

The main procedure
The main procedure, which has an empty name, is the procedure run when the program starts. It can be defined to take either one or two arguments. If it takes one argument, the argument is the program's input on entry and the program's output on exit. If it takes two arguments, the argument closest to the procedure body on each side is input or output, and the other argument is the bit bucket. The bit bucket contains unpredictable bits on entry and may contain anything on exit.

Each byte of input or output is encoded as nine bits. The bit closest to the top of the stack is 1, indicating that there is, in fact, another byte of input or output on the stack; the next eight bits are the byte, with the least significant bit at the top.

External resources

 * Kayak Essie Entry
 * Kayak in the Esoteric File Archive